NegotiateStream.AuthenticateAsServer 方法

定义

处理客户端-服务器连接的身份验证的服务器端。Handles the server side of an authentication for a client-server connection.

重载

AuthenticateAsServer(NetworkCredential, ExtendedProtectionPolicy, ProtectionLevel, TokenImpersonationLevel)

服务器调用此方法,以便对客户端-服务器连接中的客户端及服务器(可选)进行身份验证。Called by servers to authenticate the client, and optionally the server, in a client-server connection. 身份验证过程使用指定的服务器凭据、身份验证选项和扩展保护策略。The authentication process uses the specified server credentials, authentication options, and extended protection policy.

AuthenticateAsServer(NetworkCredential, ProtectionLevel, TokenImpersonationLevel)

服务器调用此方法,以便对客户端-服务器连接中的客户端及服务器(可选)进行身份验证。Called by servers to authenticate the client, and optionally the server, in a client-server connection. 身份验证过程使用指定的服务器凭据和身份验证选项。The authentication process uses the specified server credentials and authentication options.

AuthenticateAsServer()

服务器调用此方法,以便对客户端-服务器连接中的客户端及服务器(可选)进行身份验证。Called by servers to authenticate the client, and optionally the server, in a client-server connection.

AuthenticateAsServer(ExtendedProtectionPolicy)

服务器调用此方法,以便对客户端-服务器连接中的客户端及服务器(可选)进行身份验证。Called by servers to authenticate the client, and optionally the server, in a client-server connection. 身份验证过程使用指定的扩展保护策略。The authentication process uses the specified extended protection policy.

注解

正在进行身份验证时,会阻止这些方法。These methods block while the authentication is in progress. 若要防止在等待身份验证完成时应用程序被阻止,请使用 BeginAuthenticateAsServer 方法。To prevent the application from blocking while waiting for the authentication to complete, use the BeginAuthenticateAsServer method.

AuthenticateAsServer(NetworkCredential, ExtendedProtectionPolicy, ProtectionLevel, TokenImpersonationLevel)

服务器调用此方法,以便对客户端-服务器连接中的客户端及服务器(可选)进行身份验证。Called by servers to authenticate the client, and optionally the server, in a client-server connection. 身份验证过程使用指定的服务器凭据、身份验证选项和扩展保护策略。The authentication process uses the specified server credentials, authentication options, and extended protection policy.

public:
 virtual void AuthenticateAsServer(System::Net::NetworkCredential ^ credential, System::Security::Authentication::ExtendedProtection::ExtendedProtectionPolicy ^ policy, System::Net::Security::ProtectionLevel requiredProtectionLevel, System::Security::Principal::TokenImpersonationLevel requiredImpersonationLevel);
public virtual void AuthenticateAsServer (System.Net.NetworkCredential credential, System.Security.Authentication.ExtendedProtection.ExtendedProtectionPolicy? policy, System.Net.Security.ProtectionLevel requiredProtectionLevel, System.Security.Principal.TokenImpersonationLevel requiredImpersonationLevel);
public virtual void AuthenticateAsServer (System.Net.NetworkCredential credential, System.Security.Authentication.ExtendedProtection.ExtendedProtectionPolicy policy, System.Net.Security.ProtectionLevel requiredProtectionLevel, System.Security.Principal.TokenImpersonationLevel requiredImpersonationLevel);
abstract member AuthenticateAsServer : System.Net.NetworkCredential * System.Security.Authentication.ExtendedProtection.ExtendedProtectionPolicy * System.Net.Security.ProtectionLevel * System.Security.Principal.TokenImpersonationLevel -> unit
override this.AuthenticateAsServer : System.Net.NetworkCredential * System.Security.Authentication.ExtendedProtection.ExtendedProtectionPolicy * System.Net.Security.ProtectionLevel * System.Security.Principal.TokenImpersonationLevel -> unit
Public Overridable Sub AuthenticateAsServer (credential As NetworkCredential, policy As ExtendedProtectionPolicy, requiredProtectionLevel As ProtectionLevel, requiredImpersonationLevel As TokenImpersonationLevel)

参数

credential
NetworkCredential

用于确立客户端身份的 NetworkCredentialThe NetworkCredential that is used to establish the identity of the client.

policy
ExtendedProtectionPolicy

用于扩展保护的 ExtendedProtectionPolicyThe ExtendedProtectionPolicy that is used for extended protection.

requiredProtectionLevel
ProtectionLevel

ProtectionLevel 值之一,指示流的安全服务。One of the ProtectionLevel values, indicating the security services for the stream.

requiredImpersonationLevel
TokenImpersonationLevel

TokenImpersonationLevel 值之一,指示服务器使用客户端凭据访问资源的方式。One of the TokenImpersonationLevel values, indicating how the server can use the client's credentials to access resources.

例外

policy 参数中传递的扩展保护策略上,CustomChannelBindingCustomServiceNames 都是 nullThe CustomChannelBinding and CustomServiceNames on the extended protection policy passed in the policy parameter are both null.

credentialnullcredential is null.

requiredImpersonationLevel 必须为 IdentificationImpersonationDelegationrequiredImpersonationLevel must be Identification, Impersonation, or Delegation,

身份验证失败。The authentication failed. 可以使用此对象尝试重新进行身份验证。You can use this object to try to r-authenticate.

身份验证失败。The authentication failed. 可以使用此对象尝试重新进行身份验证。You can use this object to retry the authentication.

已进行了身份验证。Authentication has already occurred.

- 或 --or-

此流先前被用作客户端尝试进行身份验证。This stream was used previously to attempt authentication as the client. 不能尝试将该流作为服务器重新进行身份验证。You cannot use the stream to retry authentication as the server.

此对象已关闭。This object has been closed.

在不支持扩展保护的平台上,policy 参数设置为 AlwaysThe policy parameter was set to Always on a platform that does not support extended protection.

注解

如果 policy 参数为 null ,则使用已设置为的扩展保护策略 PolicyEnforcement NeverIf the policy parameter is null, then an extended protection policy is used that has PolicyEnforcement set to Never.

当身份验证成功时,必须检查 IsEncryptedIsSigned 属性,以确定所使用的安全服务 NegotiateStreamWhen authentication succeeds, you must check the IsEncrypted and IsSigned properties to determine what security services are used by the NegotiateStream. 检查 IsMutuallyAuthenticated 属性以确定是否发生了相互身份验证。Check the IsMutuallyAuthenticated property to determine whether mutual authentication occurred.

此方法将在操作完成之前一直阻止。This method blocks until the operation completes. 若要在操作完成前阻止阻止,请使用 BeginAuthenticateAsServer 方法重载之一。To prevent blocking until the operation completes, use one of the BeginAuthenticateAsServer method overloads.

如果身份验证失败,你将收到 AuthenticationExceptionInvalidCredentialExceptionIf the authentication fails, you receive an AuthenticationException or an InvalidCredentialException. 在这种情况下,你可以使用不同的凭据重试身份验证。In this case, you can retry the authentication with a different credential.

另请参阅

适用于

AuthenticateAsServer(NetworkCredential, ProtectionLevel, TokenImpersonationLevel)

服务器调用此方法,以便对客户端-服务器连接中的客户端及服务器(可选)进行身份验证。Called by servers to authenticate the client, and optionally the server, in a client-server connection. 身份验证过程使用指定的服务器凭据和身份验证选项。The authentication process uses the specified server credentials and authentication options.

public:
 virtual void AuthenticateAsServer(System::Net::NetworkCredential ^ credential, System::Net::Security::ProtectionLevel requiredProtectionLevel, System::Security::Principal::TokenImpersonationLevel requiredImpersonationLevel);
public virtual void AuthenticateAsServer (System.Net.NetworkCredential credential, System.Net.Security.ProtectionLevel requiredProtectionLevel, System.Security.Principal.TokenImpersonationLevel requiredImpersonationLevel);
abstract member AuthenticateAsServer : System.Net.NetworkCredential * System.Net.Security.ProtectionLevel * System.Security.Principal.TokenImpersonationLevel -> unit
override this.AuthenticateAsServer : System.Net.NetworkCredential * System.Net.Security.ProtectionLevel * System.Security.Principal.TokenImpersonationLevel -> unit
Public Overridable Sub AuthenticateAsServer (credential As NetworkCredential, requiredProtectionLevel As ProtectionLevel, requiredImpersonationLevel As TokenImpersonationLevel)

参数

credential
NetworkCredential

用于确立服务器身份的 NetworkCredentialThe NetworkCredential that is used to establish the identity of the server.

requiredProtectionLevel
ProtectionLevel

ProtectionLevel 值之一,指示流的安全服务。One of the ProtectionLevel values, indicating the security services for the stream.

requiredImpersonationLevel
TokenImpersonationLevel

TokenImpersonationLevel 值之一,指示服务器使用客户端凭据访问资源的方式。One of the TokenImpersonationLevel values, indicating how the server can use the client's credentials to access resources.

例外

credentialnullcredential is null.

requiredImpersonationLevel 必须为 IdentificationImpersonationDelegationrequiredImpersonationLevel must be Identification, Impersonation, or Delegation,

身份验证失败。The authentication failed. 可以使用此对象尝试重新进行身份验证。You can use this object to try to r-authenticate.

身份验证失败。The authentication failed. 可以使用此对象尝试重新进行身份验证。You can use this object to retry the authentication.

此对象已关闭。This object has been closed.

已进行了身份验证。Authentication has already occurred.

- 或 --or-

此流先前被用作客户端尝试进行身份验证。This stream was used previously to attempt authentication as the client. 不能尝试将该流作为服务器重新进行身份验证。You cannot use the stream to retry authentication as the server.

注解

当身份验证成功时,必须检查 IsEncryptedIsSigned 属性,以确定所使用的安全服务 NegotiateStreamWhen authentication succeeds, you must check the IsEncrypted and IsSigned properties to determine what security services are used by the NegotiateStream. 检查 IsMutuallyAuthenticated 属性以确定是否发生了相互身份验证。Check the IsMutuallyAuthenticated property to determine whether mutual authentication occurred.

此方法将在操作完成之前一直阻止。This method blocks until the operation completes. 若要在操作完成前阻止阻止,请使用 BeginAuthenticateAsServer 方法重载之一。To prevent blocking until the operation completes, use one of the BeginAuthenticateAsServer method overloads.

如果身份验证失败,你将收到 AuthenticationExceptionInvalidCredentialExceptionIf the authentication fails, you receive an AuthenticationException or an InvalidCredentialException. 在这种情况下,你可以使用不同的凭据重试身份验证。In this case, you can retry the authentication with a different credential.

适用于

AuthenticateAsServer()

服务器调用此方法,以便对客户端-服务器连接中的客户端及服务器(可选)进行身份验证。Called by servers to authenticate the client, and optionally the server, in a client-server connection.

public:
 virtual void AuthenticateAsServer();
public virtual void AuthenticateAsServer ();
abstract member AuthenticateAsServer : unit -> unit
override this.AuthenticateAsServer : unit -> unit
Public Overridable Sub AuthenticateAsServer ()

例外

身份验证失败。The authentication failed. 可以使用此对象尝试重新进行身份验证。You can use this object to retry the authentication.

身份验证失败。The authentication failed. 可以使用此对象尝试重新进行身份验证。You can use this object to retry the authentication.

此对象已关闭。This object has been closed.

注解

身份验证使用服务器的 DefaultCredentialsThe authentication uses the server's DefaultCredentials. 未为服务器指定任何服务主体名称 (SPN) 。No Service Principal Name (SPN) is specified for the server. 模拟级别为 Identification ,安全级别为 EncryptAndSignThe impersonation level is Identification, and the security level is EncryptAndSign.

当身份验证成功时,必须检查 IsEncryptedIsSigned 属性,以确定所使用的安全服务 NegotiateStreamWhen authentication succeeds, you must check the IsEncrypted and IsSigned properties to determine what security services are used by the NegotiateStream. 检查 IsMutuallyAuthenticated 属性以确定是否发生了相互身份验证。Check the IsMutuallyAuthenticated property to determine whether mutual authentication occurred.

此方法将在操作完成之前一直阻止。This method blocks until the operation completes. 若要在操作完成前阻止阻止,请使用 BeginAuthenticateAsServer 方法重载之一。To prevent blocking until the operation completes, use one of the BeginAuthenticateAsServer method overloads.

如果身份验证失败,你将收到 AuthenticationExceptionInvalidCredentialExceptionIf the authentication fails, you receive an AuthenticationException or an InvalidCredentialException. 在这种情况下,你可以使用不同的凭据重试身份验证。In this case, you can retry the authentication with a different credential.

适用于

AuthenticateAsServer(ExtendedProtectionPolicy)

服务器调用此方法,以便对客户端-服务器连接中的客户端及服务器(可选)进行身份验证。Called by servers to authenticate the client, and optionally the server, in a client-server connection. 身份验证过程使用指定的扩展保护策略。The authentication process uses the specified extended protection policy.

public:
 virtual void AuthenticateAsServer(System::Security::Authentication::ExtendedProtection::ExtendedProtectionPolicy ^ policy);
public virtual void AuthenticateAsServer (System.Security.Authentication.ExtendedProtection.ExtendedProtectionPolicy? policy);
public virtual void AuthenticateAsServer (System.Security.Authentication.ExtendedProtection.ExtendedProtectionPolicy policy);
abstract member AuthenticateAsServer : System.Security.Authentication.ExtendedProtection.ExtendedProtectionPolicy -> unit
override this.AuthenticateAsServer : System.Security.Authentication.ExtendedProtection.ExtendedProtectionPolicy -> unit
Public Overridable Sub AuthenticateAsServer (policy As ExtendedProtectionPolicy)

参数

policy
ExtendedProtectionPolicy

用于扩展保护的 ExtendedProtectionPolicyThe ExtendedProtectionPolicy that is used for extended protection.

例外

policy 参数中传递的扩展保护策略上,CustomChannelBindingCustomServiceNames 都是 nullThe CustomChannelBinding and CustomServiceNames on the extended protection policy passed in the policy parameter are both null.

身份验证失败。The authentication failed. 可以使用此对象尝试重新进行身份验证。You can use this object to retry the authentication.

身份验证失败。The authentication failed. 可以使用此对象尝试重新进行身份验证。You can use this object to retry the authentication.

此对象已关闭。This object has been closed.

在不支持扩展保护的平台上,policy 参数设置为 AlwaysThe policy parameter was set to Always on a platform that does not support extended protection.

注解

身份验证使用服务器的 DefaultCredentialsThe authentication uses the server's DefaultCredentials. 未为服务器指定任何服务主体名称 (SPN) 。No Service Principal Name (SPN) is specified for the server. 模拟级别为 Identification ,安全级别为 EncryptAndSignThe impersonation level is Identification, and the security level is EncryptAndSign.

如果 policy 参数为 null ,则使用已设置为的扩展保护策略 PolicyEnforcement NeverIf the policy parameter is null, then an extended protection policy is used that has PolicyEnforcement set to Never.

当身份验证成功时,必须检查 IsEncryptedIsSigned 属性,以确定所使用的安全服务 NegotiateStreamWhen authentication succeeds, you must check the IsEncrypted and IsSigned properties to determine what security services are used by the NegotiateStream. 检查 IsMutuallyAuthenticated 属性以确定是否发生了相互身份验证。Check the IsMutuallyAuthenticated property to determine whether mutual authentication occurred.

此方法将在操作完成之前一直阻止。This method blocks until the operation completes. 若要在操作完成前阻止阻止,请使用 BeginAuthenticateAsServer 方法重载之一。To prevent blocking until the operation completes, use one of the BeginAuthenticateAsServer method overloads.

如果身份验证失败,你将收到 AuthenticationExceptionInvalidCredentialExceptionIf the authentication fails, you receive an AuthenticationException or an InvalidCredentialException. 在这种情况下,你可以使用不同的凭据重试身份验证。In this case, you can retry the authentication with a different credential.

另请参阅

适用于