HttpListener.UnsafeConnectionNtlmAuthentication Свойство

Определение

Возвращает или задает значение Boolean, которое определяет, должны ли дополнительные запросы, использующие то же TCP-подключение, проходить аутентификацию при использовании протокола NTLM.

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

Значение свойства

Значение true, если сведения об идентификации IIdentity первого запроса будут использоваться для последующих запросов на том же подключении, в противном случае — false. Значение по умолчанию — false.

Исключения

Объект закрыт.

Примеры

В следующем примере кода показано задание этого свойства.

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

Комментарии

Если этому свойству true присвоено значение и первый запрос через определенное TCP-подключение проходит проверку подлинности с помощью NTLM, последующие запросы по тому же TCP-подключению обрабатываются с использованием сведений о проверке подлинности (IIdentity) начального запроса.

Это свойство не имеет значения, если NTLM не является протоколом проверки подлинности. Если в качестве протокола проверки подлинности указан параметр Negotiate, это свойство действует только в том случае, если ntlm является фактическим протоколом, используемым для проверки подлинности.

Примечание

Хотя установка этого свойства на true повышает производительность, так как HttpListener не отправляет дополнительные запросы проверки подлинности NTLM, существует риск безопасности, поскольку не требуется, чтобы все запросы предоставляли сведения о проверке подлинности. Необходимо определить, стоит ли снижать безопасность с целью увеличения производительности.

Применяется к