HttpListener.AuthenticationSchemes 속성

정의

클라이언트를 인증하는 데 사용되는 인증 체계를 가져오거나 설정합니다.

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

속성 값

클라이언트 인증 방법을 나타내는 AuthenticationSchemes 열거형 값의 비트 조합입니다. 기본값은 Anonymous입니다.

예외

이 개체가 닫힌 경우.

예제

다음 코드 예제를 사용 하 여 보여 줍니다는 AuthenticationSchemes 인증 체계를 지정 하는 속성입니다.

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

설명

HttpListener 지정된 체계를 사용하여 들어오는 모든 요청을 인증합니다. 및 EndGetContext 메서드는 GetContext 가 요청을 성공적으로 인증하는 경우에만 HttpListener 들어오는 클라이언트 요청을 반환합니다.

속성을 사용하여 성공적으로 인증된 클라이언트의 ID를 심문할 HttpListenerContext.User 수 있습니다.

개체가 HttpListener 수신하는 요청의 특성(예: 요청 Url 또는 UserHostName 속성)에 따라 다른 인증 메커니즘을 사용하려면 인증 체계를 선택하는 메서드를 구현해야 합니다. 이 작업을 수행하는 방법에 대한 지침은 속성 설명서를 참조 AuthenticationSchemeSelectorDelegate 하세요.

참고

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

적용 대상