AuthenticationSchemes AuthenticationSchemes AuthenticationSchemes AuthenticationSchemes Enum

定义

指定身份验证的协议。Specifies protocols for authentication.

此枚举有一个 FlagsAttribute 属性,允许按位组合成员值。

public enum class AuthenticationSchemes
[System.Flags]
public enum AuthenticationSchemes
type AuthenticationSchemes = 
Public Enum AuthenticationSchemes
继承
AuthenticationSchemesAuthenticationSchemesAuthenticationSchemesAuthenticationSchemes
属性

字段

Anonymous Anonymous Anonymous Anonymous 32768

指定匿名身份验证。Specifies anonymous authentication.

Basic Basic Basic Basic 8

指定基本身份验证。Specifies basic authentication.

Digest Digest Digest Digest 1

指定摘要式身份验证。Specifies digest authentication.

IntegratedWindowsAuthentication IntegratedWindowsAuthentication IntegratedWindowsAuthentication IntegratedWindowsAuthentication 6

指定 Windows 身份验证。Specifies Windows authentication.

Negotiate Negotiate Negotiate Negotiate 2

使用客户端,以确定身份验证方案进行协商。Negotiates with the client to determine the authentication scheme. 如果客户端和服务器均支持 Kerberos,则使用 Kerberos;否则使用 NTLM。If both client and server support Kerberos, it is used; otherwise, NTLM is used.

None None None None 0

允许无身份验证。No authentication is allowed. 客户端请求HttpListener设置了此标志的对象将始终接收 403 Forbidden 状态。A client requesting an HttpListener object with this flag set will always receive a 403 Forbidden status. 资源应永远不会提供给客户端时,请使用此标志。Use this flag when a resource should never be served to a client.

Ntlm Ntlm Ntlm Ntlm 4

指定 NTLM 身份验证。Specifies NTLM authentication.

示例

下面的代码示例演示如何使用 Negotiate 枚举值指定的客户端进行身份验证使用 Negotiate 安全协议。The following code example demonstrates using the Negotiate enumeration value to specify that clients are authenticated using the Negotiate security protocol.

Console.WriteLine("Listening for {0} prefixes...", listener.Prefixes.Count);
HttpListenerContext context = listener.GetContext();
HttpListenerRequest request = context.Request;
Console.WriteLine("Received a request.");
// This server requires a valid client certificate
// for requests that are not sent from the local computer.

// Did the client omit the certificate or send an invalid certificate?
if (request.IsAuthenticated &&
    request.GetClientCertificate() == null || 
    request.ClientCertificateError != 0)
{
    // Send a 403 response.
    HttpListenerResponse badCertificateResponse = context.Response ;
    SendBadCertificateResponse(badCertificateResponse);
    Console.WriteLine("Client has invalid certificate.");
    continue;
}
Console.WriteLine("Listening for {0} prefixes...", listener.Prefixes.Count)
Dim context As HttpListenerContext = listener.GetContext()
Dim request As HttpListenerRequest = context.Request
Console.WriteLine("Received a request.")
' This server requires a valid client certificate
' for requests that are not sent from the local computer.

' Did the client omit the certificate or send an invalid certificate?
If request.IsAuthenticated AndAlso request.GetClientCertificate() Is Nothing OrElse request.ClientCertificateError <> 0 Then
    ' Send a 403 response.
    Dim badCertificateResponse As HttpListenerResponse = context.Response
    SendBadCertificateResponse(badCertificateResponse)
    Console.WriteLine("Client has invalid certificate.")
    Continue Do
End If

注解

此枚举用于指定用来对正在处理的客户端请求进行身份验证的方法HttpListener对象。This enumeration is used to specify the method used to authenticate client requests being processed by HttpListener objects.

重要

基本身份验证要求密码的交换,因此应当避免在安全的加密连接的情况下除外。Basic authentication requires the exchange of a password and should therefore be avoided except in the case of secure, encrypted connections.

有关详细信息基本和摘要式身份验证,请参阅RFC2617-HTTP 身份验证:基本和摘要式身份验证For additional information on basic and digest authentication, see RFC2617 - HTTP Authentication: Basic and Digest Authentication. 本文档位于https://www.rfc-editor.orgThis document is available at https://www.rfc-editor.org.

适用于