AuthenticationSchemeSelector AuthenticationSchemeSelector AuthenticationSchemeSelector AuthenticationSchemeSelector Delegate

정의

HttpListener 인스턴스에 대한 인증 체계를 선택합니다.Selects the authentication scheme for an HttpListener instance.

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 

매개 변수

httpRequest
HttpListenerRequest HttpListenerRequest HttpListenerRequest HttpListenerRequest

인증 체계를 선택할 해당 HttpListenerRequest 인스턴스입니다.The HttpListenerRequest instance for which to select an authentication scheme.

반환 값

System.Net.AuthenticationSchemes

지정된 클라이언트 요청에 대해 사용할 인증 방법을 나타내는 AuthenticationSchemes 값 중 하나입니다.One of the AuthenticationSchemes values that indicates the method of authentication to use for the specified client request.

상속
AuthenticationSchemeSelectorAuthenticationSchemeSelectorAuthenticationSchemeSelectorAuthenticationSchemeSelector

예제

다음 예제에서는이 형식의 인스턴스를 사용 하 여 설정 하 여 AuthenticationSchemeSelectorDelegate 속성입니다.The following example uses an instance of this type to set the AuthenticationSchemeSelectorDelegate property.

// 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()

다음 예제에서는 호출한 메서드의 구현을 보여 줍니다는 AuthenticationSchemeSelector 앞의 예제에 위임 합니다.The following example shows the implementation of the method invoked by the AuthenticationSchemeSelector delegate in the previous example.

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

설명

이 형식의 대리자에서 사용 하는 HttpListener 요청의 특성을 기반으로 하는 인스턴스를 인증 체계를 선택 합니다.Delegates of this type are used by HttpListener instances to select an authentication scheme based on the characteristics of a request.

AuthenticationSchemeSelector 대리자에 전달 되는 HttpListenerRequest 인증 정보를 제공 되지 않은 들어오는 각 요청에 대 한 개체입니다.An AuthenticationSchemeSelector delegate is passed an HttpListenerRequest object for each incoming request that has not provided authentication information. 대리자가 호출 하는 메서드를 사용 하는 HttpListenerRequest 개체 및 다른 사용 가능한 정보를 요구 하는 인증 체계를 결정 합니다.The method invoked by the delegate uses the HttpListenerRequest object and any other available information to decide which authentication scheme to require. 대리자를 사용 하 여 지정 된 된 AuthenticationSchemeSelectorDelegate 속성입니다.The delegate is specified by using the AuthenticationSchemeSelectorDelegate property.

확장 메서드

GetMethodInfo(Delegate) GetMethodInfo(Delegate) GetMethodInfo(Delegate) GetMethodInfo(Delegate)

지정된 대리자가 나타내는 메서드를 나타내는 개체를 가져옵니다.Gets an object that represents the method represented by the specified delegate.

적용 대상