NegotiateStream.AuthenticateAsServerAsync 方法

定义

以异步操作方式处理某个客户端-服务器连接的身份验证的服务器端。

重载

AuthenticateAsServerAsync()

服务器调用此方法,对客户端-服务器连接中的客户端及服务器(可选)进行身份验证以作为异步操作。

AuthenticateAsServerAsync(ExtendedProtectionPolicy)

服务器调用此方法,对客户端-服务器连接中的客户端及服务器(可选)进行身份验证以作为异步操作。 身份验证过程使用指定的扩展保护策略。

AuthenticateAsServerAsync(NetworkCredential, ProtectionLevel, TokenImpersonationLevel)

服务器调用此方法,对客户端-服务器连接中的客户端及服务器(可选)进行身份验证以作为异步操作。 身份验证过程使用指定的服务器凭据和身份验证选项。

AuthenticateAsServerAsync(NetworkCredential, ExtendedProtectionPolicy, ProtectionLevel, TokenImpersonationLevel)

服务器调用此方法,对客户端-服务器连接中的客户端及服务器(可选)进行身份验证以作为异步操作。 身份验证过程使用指定的服务器凭据、身份验证选项和扩展保护策略。

AuthenticateAsServerAsync()

Source:
NegotiateStream.cs
Source:
NegotiateStream.cs
Source:
NegotiateStream.cs

服务器调用此方法,对客户端-服务器连接中的客户端及服务器(可选)进行身份验证以作为异步操作。

public virtual System.Threading.Tasks.Task AuthenticateAsServerAsync ();

返回

表示异步操作的任务对象。

例外

身份验证失败。 可以使用此对象尝试重新进行身份验证。

身份验证失败。 可以使用此对象尝试重新进行身份验证。

此对象已关闭。

不支持 windows 95 和 Windows 98。

注解

身份验证使用服务器的 DefaultCredentials。 未为服务器指定服务主体名称 (SPN) 。 模拟级别为 Identification,安全级别为 EncryptAndSign

身份验证成功后,必须检查 IsEncryptedIsSigned 属性来确定 所使用的NegotiateStream安全服务。 IsMutuallyAuthenticated检查 属性以确定是否发生了相互身份验证。

如果身份验证失败,则会收到 AuthenticationExceptionInvalidCredentialException。 在这种情况下,可以使用其他凭据重试身份验证。

此方法将存储在任务中,它返回该方法的同步对应项可能引发的所有非使用异常。 如果异常存储在返回的任务中,则在等待任务时将引发该异常。 使用异常(如 ArgumentException)仍会同步引发。 有关存储的异常,请参阅 引发的 AuthenticateAsServer()异常。

适用于

.NET 9 和其他版本
产品 版本
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Framework 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1

AuthenticateAsServerAsync(ExtendedProtectionPolicy)

Source:
NegotiateStream.cs
Source:
NegotiateStream.cs
Source:
NegotiateStream.cs

服务器调用此方法,对客户端-服务器连接中的客户端及服务器(可选)进行身份验证以作为异步操作。 身份验证过程使用指定的扩展保护策略。

public virtual System.Threading.Tasks.Task AuthenticateAsServerAsync (System.Security.Authentication.ExtendedProtection.ExtendedProtectionPolicy? policy);
public virtual System.Threading.Tasks.Task AuthenticateAsServerAsync (System.Security.Authentication.ExtendedProtection.ExtendedProtectionPolicy policy);

参数

policy
ExtendedProtectionPolicy

用于扩展保护的 ExtendedProtectionPolicy

返回

表示异步操作的任务对象。

例外

policy 参数中传递的扩展保护策略上,CustomChannelBindingCustomServiceNames 都是 null

身份验证失败。 可以使用此对象尝试重新进行身份验证。

身份验证失败。 可以使用此对象尝试重新进行身份验证。

此对象已关闭。

在不支持扩展保护的平台上,policy 参数设置为 Always

不支持 windows 95 和 Windows 98。

注解

身份验证使用服务器的 DefaultCredentials。 未为服务器指定服务主体名称 (SPN) 。 模拟级别为 Identification,安全级别为 EncryptAndSign

policy如果 参数为 null,则使用已设置为 NeverPolicyEnforcement扩展保护策略。

身份验证成功后,必须检查 IsEncryptedIsSigned 属性来确定 所使用的NegotiateStream安全服务。 IsMutuallyAuthenticated检查 属性以确定是否发生了相互身份验证。

如果身份验证失败,则会收到 AuthenticationExceptionInvalidCredentialException。 在这种情况下,可以使用其他凭据重试身份验证。

此方法将存储在任务中,它返回该方法的同步对应项可能引发的所有非使用异常。 如果异常存储在返回的任务中,则在等待任务时将引发该异常。 使用异常(如 ArgumentException)仍会同步引发。 有关存储的异常,请参阅 引发的 AuthenticateAsServer(ExtendedProtectionPolicy)异常。

另请参阅

适用于

.NET 9 和其他版本
产品 版本
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Framework 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1

AuthenticateAsServerAsync(NetworkCredential, ProtectionLevel, TokenImpersonationLevel)

Source:
NegotiateStream.cs
Source:
NegotiateStream.cs
Source:
NegotiateStream.cs

服务器调用此方法,对客户端-服务器连接中的客户端及服务器(可选)进行身份验证以作为异步操作。 身份验证过程使用指定的服务器凭据和身份验证选项。

public virtual System.Threading.Tasks.Task AuthenticateAsServerAsync (System.Net.NetworkCredential credential, System.Net.Security.ProtectionLevel requiredProtectionLevel, System.Security.Principal.TokenImpersonationLevel requiredImpersonationLevel);

参数

credential
NetworkCredential

用于确立服务器身份的 NetworkCredential

requiredProtectionLevel
ProtectionLevel

ProtectionLevel 值之一,指示流的安全服务。

requiredImpersonationLevel
TokenImpersonationLevel

TokenImpersonationLevel 值之一,指示服务器使用客户端凭据访问资源的方式。

返回

表示异步操作的任务对象。

例外

credentialnull

requiredImpersonationLevel 必须为 IdentificationImpersonationDelegation

身份验证失败。 可以使用此对象尝试重新进行身份验证。

身份验证失败。 可以使用此对象尝试重新进行身份验证。

此对象已关闭。

已进行了身份验证。

- 或 -

此流先前被用作客户端尝试进行身份验证。 不能尝试将该流作为服务器重新进行身份验证。

不支持 windows 95 和 Windows 98。

注解

身份验证成功后,必须检查 IsEncryptedIsSigned 属性来确定 所使用的NegotiateStream安全服务。 IsMutuallyAuthenticated检查 属性以确定是否发生了相互身份验证。

如果身份验证失败,则会收到 AuthenticationExceptionInvalidCredentialException。 在这种情况下,可以使用其他凭据重试身份验证。

此方法将存储在任务中,它返回该方法的同步对应项可能引发的所有非使用异常。 如果异常存储在返回的任务中,则在等待任务时将引发该异常。 使用异常(如 ArgumentException)仍会同步引发。 有关存储的异常,请参阅 引发的 AuthenticateAsServer(NetworkCredential, ProtectionLevel, TokenImpersonationLevel)异常。

适用于

.NET 9 和其他版本
产品 版本
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Framework 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1

AuthenticateAsServerAsync(NetworkCredential, ExtendedProtectionPolicy, ProtectionLevel, TokenImpersonationLevel)

Source:
NegotiateStream.cs
Source:
NegotiateStream.cs
Source:
NegotiateStream.cs

服务器调用此方法,对客户端-服务器连接中的客户端及服务器(可选)进行身份验证以作为异步操作。 身份验证过程使用指定的服务器凭据、身份验证选项和扩展保护策略。

public virtual System.Threading.Tasks.Task AuthenticateAsServerAsync (System.Net.NetworkCredential credential, System.Security.Authentication.ExtendedProtection.ExtendedProtectionPolicy? policy, System.Net.Security.ProtectionLevel requiredProtectionLevel, System.Security.Principal.TokenImpersonationLevel requiredImpersonationLevel);
public virtual System.Threading.Tasks.Task AuthenticateAsServerAsync (System.Net.NetworkCredential credential, System.Security.Authentication.ExtendedProtection.ExtendedProtectionPolicy policy, System.Net.Security.ProtectionLevel requiredProtectionLevel, System.Security.Principal.TokenImpersonationLevel requiredImpersonationLevel);

参数

credential
NetworkCredential

用于确立客户端身份的 NetworkCredential

policy
ExtendedProtectionPolicy

用于扩展保护的 ExtendedProtectionPolicy

requiredProtectionLevel
ProtectionLevel

ProtectionLevel 值之一,指示流的安全服务。

requiredImpersonationLevel
TokenImpersonationLevel

TokenImpersonationLevel 值之一,指示服务器使用客户端凭据访问资源的方式。

返回

表示异步操作的任务对象。

例外

policy 参数中传递的扩展保护策略上,CustomChannelBindingCustomServiceNames 都是 null

credentialnull

requiredImpersonationLevel 必须为 IdentificationImpersonationDelegation

身份验证失败。 可以使用此对象尝试重新进行身份验证。

身份验证失败。 可以使用此对象尝试重新进行身份验证。

已进行了身份验证。

- 或 -

此流先前被用作客户端尝试进行身份验证。 不能尝试将该流作为服务器重新进行身份验证。

此对象已关闭。

在不支持扩展保护的平台上,policy 参数设置为 Always

不支持 windows 95 和 Windows 98。

注解

policy如果 参数为 null,则使用已设置为 NeverPolicyEnforcement扩展保护策略。

身份验证成功后,必须检查 IsEncryptedIsSigned 属性来确定 所使用的NegotiateStream安全服务。 IsMutuallyAuthenticated检查 属性以确定是否发生了相互身份验证。

如果身份验证失败,则会收到 AuthenticationExceptionInvalidCredentialException。 在这种情况下,可以使用其他凭据重试身份验证。

此方法将存储在任务中,它返回该方法的同步对应项可能引发的所有非使用异常。 如果异常存储在返回的任务中,则在等待任务时将引发该异常。 使用异常(如 ArgumentException)仍会同步引发。 有关存储的异常,请参阅 引发的 AuthenticateAsServer(NetworkCredential, ExtendedProtectionPolicy, ProtectionLevel, TokenImpersonationLevel)异常。

另请参阅

适用于

.NET 9 和其他版本
产品 版本
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Framework 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1