HttpListener.UnsafeConnectionNtlmAuthentication Propiedad

Definición

Obtiene o establece un valor Boolean que controla si, cuando se utiliza NTLM, se requieren solicitudes adicionales que utilicen la misma conexión del protocolo TCP (Protocolo de control de transmisión) para la autenticación.

public:
 property bool UnsafeConnectionNtlmAuthentication { bool get(); void set(bool value); };
public bool UnsafeConnectionNtlmAuthentication { get; set; }
member this.UnsafeConnectionNtlmAuthentication : bool with get, set
Public Property UnsafeConnectionNtlmAuthentication As Boolean

Valor de propiedad

Es true si el objeto IIdentity de la primera solicitud debe utilizarse para las solicitudes posteriores de la misma conexión; de lo contrario, es false. El valor predeterminado es false.

Excepciones

Este objeto se ha cerrado.

Ejemplos

En el ejemplo de código siguiente se muestra cómo establecer esta propiedad.

public static void SimpleListenerWithUnsafeAuthentication(string[] prefixes)
{
    // URI prefixes are required,
    // for example "http://contoso.com:8080/index/".
    if (prefixes == null || prefixes.Length == 0)
      throw new ArgumentException("prefixes");
    // Set up a listener.
    HttpListener listener = new HttpListener();
    foreach (string s in prefixes)
    {
        listener.Prefixes.Add(s);
    }
    listener.Start();
    // Specify Negotiate as the authentication scheme.
    listener.AuthenticationSchemes = AuthenticationSchemes.Negotiate;
    // If NTLM is used, we will allow multiple requests on the same
    // connection to use the authentication information of first request.
    // This improves performance but does reduce the security of your
    // application.
    listener.UnsafeConnectionNtlmAuthentication = true;
    // This listener does not want to receive exceptions
    // that occur when sending the response to the client.
    listener.IgnoreWriteExceptions = true;
    Console.WriteLine("Listening...");
    // ... process requests here.

    listener.Close();
}
Public Shared Sub SimpleListenerWithUnsafeAuthentication(ByVal prefixes As String())
    ' URI prefixes are required,
    ' for example "http://contoso.com:8080/index/".
    If prefixes Is Nothing OrElse prefixes.Length = 0 Then Throw New ArgumentException("prefixes")
    ' Set up a listener.
    Dim listener As HttpListener = New HttpListener()

    For Each s As String In prefixes
        listener.Prefixes.Add(s)
    Next

    listener.Start()
    ' Specify Negotiate as the authentication scheme.
    listener.AuthenticationSchemes = AuthenticationSchemes.Negotiate
    ' If NTLM Is used, we will allow multiple requests on the same
    ' connection to use the authentication information of first request.
    ' This improves performance but does reduce the security of your 
    ' application. 
    listener.UnsafeConnectionNtlmAuthentication = True
    ' This listener does Not want to receive exceptions 
    ' that occur when sending the response to the client.
    listener.IgnoreWriteExceptions = True
    Console.WriteLine("Listening...")
    ' ... process requests here.

    listener.Close()
End Sub

Comentarios

Cuando esta propiedad se establece true en y la primera solicitud a través de una conexión TCP determinada se autentica mediante NTLM, las solicitudes posteriores a través de la misma conexión TCP se procesan mediante la información de autenticación (IIdentity) de la solicitud inicial.

Esta propiedad no tiene ningún efecto si el protocolo de autenticación no es NTLM. Cuando Negotiate se especifica como protocolo de autenticación, esta propiedad solo tiene un efecto si NTLM es el protocolo real que se usa para la autenticación.

Nota:

Aunque establecer esta propiedad true en aumenta el HttpListener rendimiento porque no envía desafíos de autenticación NTLM adicionales, existe un riesgo de seguridad en no requerir todas las solicitudes para proporcionar información de autenticación. Estudie si el aumento de rendimiento compensa este riesgo.

Se aplica a