Share via


HttpListener.AuthenticationSchemes Özellik

Tanım

İstemcilerin kimliğini doğrulamak için kullanılan düzeni alır veya ayarlar.

public:
 property System::Net::AuthenticationSchemes AuthenticationSchemes { System::Net::AuthenticationSchemes get(); void set(System::Net::AuthenticationSchemes value); };
public System.Net.AuthenticationSchemes AuthenticationSchemes { get; set; }
member this.AuthenticationSchemes : System.Net.AuthenticationSchemes with get, set
Public Property AuthenticationSchemes As AuthenticationSchemes

Özellik Değeri

İstemcilerin kimlik doğrulamasının AuthenticationSchemes nasıl yapılacağını gösteren sabit listesi değerlerinin bit düzeyinde birleşimi. Anonymous varsayılan değerdir.

Özel durumlar

Bu nesne kapatıldı.

Örnekler

Aşağıdaki kod örneği, bir kimlik doğrulama şeması belirtmek için özelliğinin kullanılmasını AuthenticationSchemes gösterir.

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

Açıklamalar

, HttpListener tüm gelen isteklerin kimliğini doğrulamak için belirtilen düzeni kullanır. GetContext ve EndGetContext yöntemleri, yalnızca isteğin HttpListener kimliğini başarıyla doğrularsa gelen bir istemci isteği döndürür.

özelliğini kullanarak HttpListenerContext.User başarıyla doğrulanmış bir istemcinin kimliğini sorgulayabilirsiniz.

Bir HttpListener nesnenin aldığı isteklerin (örneğin, isteğin veya UserHostName özelliğinin) özelliklerine göre farklı kimlik doğrulama mekanizmaları kullanmasını istiyorsanız, Url kimlik doğrulama düzenini seçen bir yöntem uygulamanız gerekir. Bunun nasıl yapılacağını açıklayan yönergeler için özellik belgelerine AuthenticationSchemeSelectorDelegate bakın.

Not

Bu özelliği Özet, NTLM veya Negotiate'i etkinleştirecek şekilde ayarlamak için , ControlPrincipalgerekirSecurityPermission.

Şunlara uygulanır