HttpListener.AuthenticationSchemeSelectorDelegate 속성

정의

클라이언트 인증에 사용되는 프로토콜을 결정하기 위해 호출되는 대리자를 가져오거나 설정합니다.

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

속성 값

AuthenticationSchemeSelector

인증 프로토콜을 선택하는 데 사용되는 메서드를 호출하는 AuthenticationSchemeSelector 대리자입니다. 기본값은 null입니다.

예외

이 개체가 닫힌 경우.

예제

다음 코드 예제에서는이 속성의 값을 설정 합니다.

// 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 제공합니다.

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에서 처리하는 모든 요청에 동일한 인증 프로토콜을 사용하려는 경우 이 속성을 설정할 필요가 없습니다. 모든 클라이언트 요청에 사용할 프로토콜을 지정하려면 이 속성을 사용합니다 AuthenticationSchemes .

클라이언트가 헤더 HttpListener 에 인증 정보를 지정하지 않은 경우 인증되지 않은 각 들어오는 요청에 대해 지정된 대리자를 호출하여 클라이언트를 인증하는 데 사용할 프로토콜(있는 경우)을 결정합니다. 및 EndGetContext 메서드는 GetContext 요청을 성공적으로 인증한 HttpListener 경우에만 들어오는 요청을 반환합니다. 요청을 인증 HttpListener 할 수 없는 경우 자동으로 401 응답을 다시 보냅니다. 속성을 사용하여 성공적으로 인증된 클라이언트의 ID를 HttpRequest.LogonUserIdentity 가져올 수 있습니다.

다양 한 애플리케이션별 메서드 인증 프로토콜을 위임할 수의 인스턴스를 하려는 경우 유용 HttpListener (수신한 요청의 특성에 따라 다양 한 인증 프로토콜을 사용 하려면 예: 요청의 Url 또는 UserHostAddress 속성).

참고

다이제스트, NTLM 또는 Negotiate를 사용하도록 설정하려면 다음이 SecurityPermissionControlPrincipal필요합니다.

적용 대상