AuthenticationSchemeSelector Temsilci

Tanım

Örnek HttpListener için kimlik doğrulama düzenini seçer.

public delegate System::Net::AuthenticationSchemes AuthenticationSchemeSelector(HttpListenerRequest ^ httpRequest);
public delegate System.Net.AuthenticationSchemes AuthenticationSchemeSelector(HttpListenerRequest httpRequest);
type AuthenticationSchemeSelector = delegate of HttpListenerRequest -> AuthenticationSchemes
Public Delegate Function AuthenticationSchemeSelector(httpRequest As HttpListenerRequest) As AuthenticationSchemes 

Parametreler

httpRequest
HttpListenerRequest

Kimlik HttpListenerRequest doğrulama düzeninin seçildiği örnek.

Dönüş Değeri

AuthenticationSchemes Belirtilen istemci isteği için kullanılacak kimlik doğrulama yöntemini gösteren değerlerden biri.

Örnekler

Aşağıdaki örnek, özelliğini ayarlamak için bu türün bir örneğini AuthenticationSchemeSelectorDelegate kullanır.

// Set up a listener.
HttpListener listener = new HttpListener();
HttpListenerPrefixCollection prefixes = listener.Prefixes;
prefixes.Add(@"http://localhost:8080/");
prefixes.Add(@"http://contoso.com:8080/");

// Specify the authentication delegate.
listener.AuthenticationSchemeSelectorDelegate =
    new AuthenticationSchemeSelector (AuthenticationSchemeForClient);

// Start listening for requests and process them
// synchronously.
listener.Start();
' Set up a listener.
Dim listener As New HttpListener()
Dim prefixes As HttpListenerPrefixCollection = listener.Prefixes
prefixes.Add("http://localhost:8080/")
prefixes.Add("http://contoso.com:8080/")

' Specify the authentication delegate.
listener.AuthenticationSchemeSelectorDelegate = New AuthenticationSchemeSelector(AddressOf AuthenticationSchemeForClient)

' Start listening for requests and process them 
' synchronously.
listener.Start()

Aşağıdaki örnekte, önceki örnekte temsilci tarafından AuthenticationSchemeSelector çağrılan yöntemin uygulanması gösterilmektedir.

static AuthenticationSchemes AuthenticationSchemeForClient(HttpListenerRequest request)
{
    Console.WriteLine("Client authentication protocol selection in progress...");
    // Do not authenticate local machine requests.
    if (request.RemoteEndPoint.Address.Equals (IPAddress.Loopback))
    {
        return AuthenticationSchemes.None;
    }
    else
    {
        return AuthenticationSchemes.IntegratedWindowsAuthentication;
    }
}
Private Shared Function AuthenticationSchemeForClient(ByVal request As HttpListenerRequest) As AuthenticationSchemes
    Console.WriteLine("Client authentication protocol selection in progress...")
    ' Do not authenticate local machine requests.
    If request.RemoteEndPoint.Address.Equals(IPAddress.Loopback) Then
        Return AuthenticationSchemes.None
    Else
        Return AuthenticationSchemes.IntegratedWindowsAuthentication
    End If
End Function

Açıklamalar

Bu tür temsilciler, bir isteğin özelliklerine göre bir kimlik doğrulama şeması seçmek için örnekler tarafından HttpListener kullanılır.

Bir AuthenticationSchemeSelector temsilciye, kimlik doğrulama bilgileri sağlanmayan her gelen istek için bir HttpListenerRequest nesne geçirilir. Temsilci tarafından çağrılan yöntem, hangi kimlik doğrulama düzeninin HttpListenerRequest gerektirildiğine karar vermek için nesnesini ve diğer kullanılabilir bilgileri kullanır. Temsilci özelliği kullanılarak AuthenticationSchemeSelectorDelegate belirtilir.

Uzantı Metotları

GetMethodInfo(Delegate)

Belirtilen temsilci tarafından temsil edilen yöntemi temsil eden bir nesnesi alır.

Şunlara uygulanır