NegotiateStream.AuthenticateAsClientAsync 方法    
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
客户端调用此方法,对客户端/服务器连接中的客户端及服务器(可选)进行身份验证以作为异步操作。
重载
| AuthenticateAsClientAsync() | 客户端调用此方法,对客户端/服务器连接中的客户端及服务器(可选)进行身份验证以作为异步操作。 | 
| AuthenticateAsClientAsync(NetworkCredential, String) | 客户端调用此方法,对客户端/服务器连接中的客户端及服务器(可选)进行身份验证以作为异步操作。 身份验证过程使用指定的客户端凭据。 | 
| AuthenticateAsClientAsync(NetworkCredential, ChannelBinding, String) | 客户端调用此方法,对客户端/服务器连接中的客户端及服务器(可选)进行身份验证以作为异步操作。 身份验证过程使用指定的客户端凭据和通道绑定。 | 
| AuthenticateAsClientAsync(NetworkCredential, String, ProtectionLevel, TokenImpersonationLevel) | 客户端调用此方法,对客户端/服务器连接中的客户端及服务器(可选)进行身份验证以作为异步操作。 身份验证过程使用指定的凭据和身份验证选项。 | 
| AuthenticateAsClientAsync(NetworkCredential, ChannelBinding, String, ProtectionLevel, TokenImpersonationLevel) | 客户端调用此方法,对客户端/服务器连接中的客户端及服务器(可选)进行身份验证以作为异步操作。 身份验证过程使用指定的凭据、身份验证选项和通道绑定。 | 
AuthenticateAsClientAsync()
- Source:
- NegotiateStream.cs
- Source:
- NegotiateStream.cs
- Source:
- NegotiateStream.cs
客户端调用此方法,对客户端/服务器连接中的客户端及服务器(可选)进行身份验证以作为异步操作。
public:
 virtual System::Threading::Tasks::Task ^ AuthenticateAsClientAsync();public virtual System.Threading.Tasks.Task AuthenticateAsClientAsync ();abstract member AuthenticateAsClientAsync : unit -> System.Threading.Tasks.Task
override this.AuthenticateAsClientAsync : unit -> System.Threading.Tasks.TaskPublic Overridable Function AuthenticateAsClientAsync () As Task返回
表示异步操作的任务对象。
例外
身份验证失败。 可以使用此对象尝试重新进行身份验证。
身份验证失败。 可以使用此对象尝试重新进行身份验证。
此对象已关闭。
注解
身份验证使用客户端的 DefaultCredentials。 未为服务器指定服务主体名称 (SPN) 。 模拟级别为 Identification,安全级别为 EncryptAndSign,请求相互身份验证。 类 NegotiateStream 将构造用于相互身份验证的 SPN。
身份验证成功后,必须检查 IsEncrypted 和 IsSigned 属性来确定 所使用的NegotiateStream安全服务。 IsMutuallyAuthenticated检查 属性以确定是否发生了相互身份验证。
如果身份验证失败,则会收到 AuthenticationException 或 InvalidCredentialException。 在这种情况下,可以使用其他凭据重试身份验证。
此方法将存储在任务中,它返回该方法的同步对应项可能引发的所有非使用异常。 如果异常存储在返回的任务中,则在等待任务时将引发该异常。 使用异常(如 ArgumentException)仍会同步引发。 有关存储的异常,请参阅 引发的 AuthenticateAsClient()异常。
适用于
AuthenticateAsClientAsync(NetworkCredential, String)
- Source:
- NegotiateStream.cs
- Source:
- NegotiateStream.cs
- Source:
- NegotiateStream.cs
客户端调用此方法,对客户端/服务器连接中的客户端及服务器(可选)进行身份验证以作为异步操作。 身份验证过程使用指定的客户端凭据。
public:
 virtual System::Threading::Tasks::Task ^ AuthenticateAsClientAsync(System::Net::NetworkCredential ^ credential, System::String ^ targetName);public virtual System.Threading.Tasks.Task AuthenticateAsClientAsync (System.Net.NetworkCredential credential, string targetName);abstract member AuthenticateAsClientAsync : System.Net.NetworkCredential * string -> System.Threading.Tasks.Task
override this.AuthenticateAsClientAsync : System.Net.NetworkCredential * string -> System.Threading.Tasks.TaskPublic Overridable Function AuthenticateAsClientAsync (credential As NetworkCredential, targetName As String) As Task参数
- credential
- NetworkCredential
用于确立客户端身份的 NetworkCredential。
- targetName
- String
唯一标识要进行身份验证的服务器的服务主体名称 (SPN)。
返回
表示异步操作的任务对象。
例外
身份验证失败。 可以使用此对象尝试重新进行身份验证。
身份验证失败。 可以使用此对象尝试重新进行身份验证。
此对象已关闭。
              targetName 为 null。
注解
模拟级别为 Identification,安全级别为 EncryptAndSign,请求相互身份验证。 类 NegotiateStream 将构造用于相互身份验证的 SPN。
身份验证成功后,必须检查 IsEncrypted 和 IsSigned 属性来确定 所使用的NegotiateStream安全服务。 IsMutuallyAuthenticated检查 属性以确定是否发生了相互身份验证。
此方法将存储在任务中,它返回该方法的同步对应项可能引发的所有非使用异常。 如果异常存储在返回的任务中,则在等待任务时将引发该异常。 使用异常(如 ArgumentException)仍会同步引发。 有关存储的异常,请参阅 引发的 AuthenticateAsClient(NetworkCredential, String)异常。
适用于
AuthenticateAsClientAsync(NetworkCredential, ChannelBinding, String)
- Source:
- NegotiateStream.cs
- Source:
- NegotiateStream.cs
- Source:
- NegotiateStream.cs
客户端调用此方法,对客户端/服务器连接中的客户端及服务器(可选)进行身份验证以作为异步操作。 身份验证过程使用指定的客户端凭据和通道绑定。
public:
 virtual System::Threading::Tasks::Task ^ AuthenticateAsClientAsync(System::Net::NetworkCredential ^ credential, System::Security::Authentication::ExtendedProtection::ChannelBinding ^ binding, System::String ^ targetName);public virtual System.Threading.Tasks.Task AuthenticateAsClientAsync (System.Net.NetworkCredential credential, System.Security.Authentication.ExtendedProtection.ChannelBinding? binding, string targetName);public virtual System.Threading.Tasks.Task AuthenticateAsClientAsync (System.Net.NetworkCredential credential, System.Security.Authentication.ExtendedProtection.ChannelBinding binding, string targetName);abstract member AuthenticateAsClientAsync : System.Net.NetworkCredential * System.Security.Authentication.ExtendedProtection.ChannelBinding * string -> System.Threading.Tasks.Task
override this.AuthenticateAsClientAsync : System.Net.NetworkCredential * System.Security.Authentication.ExtendedProtection.ChannelBinding * string -> System.Threading.Tasks.TaskPublic Overridable Function AuthenticateAsClientAsync (credential As NetworkCredential, binding As ChannelBinding, targetName As String) As Task参数
- credential
- NetworkCredential
用于确立客户端身份的 NetworkCredential。
- binding
- ChannelBinding
用于扩展保护的 ChannelBinding。
- targetName
- String
唯一标识要进行身份验证的服务器的服务主体名称 (SPN)。
返回
表示异步操作的任务对象。
例外
身份验证失败。 可以使用此对象尝试重新进行身份验证。
身份验证失败。 可以使用此对象尝试重新进行身份验证。
此对象已关闭。
注解
模拟级别为 Identification,安全级别为 EncryptAndSign,请求相互身份验证。 类 NegotiateStream 将构造用于相互身份验证的 SPN。
              ChannelBinding应用程序将从关联的 SslStream上的 属性检索TransportContext传递给参数中binding此方法的用于扩展保护的 。
身份验证成功后,必须检查 IsEncrypted 和 IsSigned 属性来确定 所使用的NegotiateStream安全服务。 IsMutuallyAuthenticated检查 属性以确定是否发生了相互身份验证。
此方法将存储在任务中,它返回该方法的同步对应项可能引发的所有非使用异常。 如果异常存储在返回的任务中,则在等待任务时将引发该异常。 使用异常(如 ArgumentException)仍会同步引发。 有关存储的异常,请参阅 引发的 AuthenticateAsClient(NetworkCredential, ChannelBinding, String)异常。
另请参阅
适用于
AuthenticateAsClientAsync(NetworkCredential, String, ProtectionLevel, TokenImpersonationLevel)
- Source:
- NegotiateStream.cs
- Source:
- NegotiateStream.cs
- Source:
- NegotiateStream.cs
客户端调用此方法,对客户端/服务器连接中的客户端及服务器(可选)进行身份验证以作为异步操作。 身份验证过程使用指定的凭据和身份验证选项。
public:
 virtual System::Threading::Tasks::Task ^ AuthenticateAsClientAsync(System::Net::NetworkCredential ^ credential, System::String ^ targetName, System::Net::Security::ProtectionLevel requiredProtectionLevel, System::Security::Principal::TokenImpersonationLevel allowedImpersonationLevel);public virtual System.Threading.Tasks.Task AuthenticateAsClientAsync (System.Net.NetworkCredential credential, string targetName, System.Net.Security.ProtectionLevel requiredProtectionLevel, System.Security.Principal.TokenImpersonationLevel allowedImpersonationLevel);abstract member AuthenticateAsClientAsync : System.Net.NetworkCredential * string * System.Net.Security.ProtectionLevel * System.Security.Principal.TokenImpersonationLevel -> System.Threading.Tasks.Task
override this.AuthenticateAsClientAsync : System.Net.NetworkCredential * string * System.Net.Security.ProtectionLevel * System.Security.Principal.TokenImpersonationLevel -> System.Threading.Tasks.TaskPublic Overridable Function AuthenticateAsClientAsync (credential As NetworkCredential, targetName As String, requiredProtectionLevel As ProtectionLevel, allowedImpersonationLevel As TokenImpersonationLevel) As Task参数
- credential
- NetworkCredential
用于确立客户端身份的 NetworkCredential。
- targetName
- String
唯一标识要进行身份验证的服务器的服务主体名称 (SPN)。
- requiredProtectionLevel
- ProtectionLevel
ProtectionLevel 值之一,指示流的安全服务。
- allowedImpersonationLevel
- TokenImpersonationLevel
TokenImpersonationLevel 值之一,指示服务器使用客户端凭据访问资源的方式。
返回
表示异步操作的任务对象。
例外
              allowedImpersonationLevel 不是有效值。
              targetName 为 null。
身份验证失败。 可以使用此对象尝试重新进行身份验证。
身份验证失败。 可以使用此对象尝试重新进行身份验证。
此对象已关闭。
注解
              requiredProtectionLevel使用 参数为使用经过身份验证的流传输的数据请求安全服务。 例如,若要对数据进行加密和签名,请 EncryptAndSign 指定 值。 成功的身份验证不保证已授予请求 ProtectionLevel 。 必须检查 IsEncrypted 和 IsSigned 属性来确定 所使用的NegotiateStream安全服务。
如果身份验证失败,则会收到 AuthenticationException 或 InvalidCredentialException。 在这种情况下,可以使用其他凭据重试身份验证。
此方法存储在任务中,它返回该方法的同步对应项可能引发的所有非使用异常。 如果异常存储在返回的任务中,则在等待任务时将引发该异常。 使用异常(如 ArgumentException)仍会同步引发。 有关存储的异常,请参阅 引发的 AuthenticateAsClient(NetworkCredential, String, ProtectionLevel, TokenImpersonationLevel)异常。
适用于
AuthenticateAsClientAsync(NetworkCredential, ChannelBinding, String, ProtectionLevel, TokenImpersonationLevel)
- Source:
- NegotiateStream.cs
- Source:
- NegotiateStream.cs
- Source:
- NegotiateStream.cs
客户端调用此方法,对客户端/服务器连接中的客户端及服务器(可选)进行身份验证以作为异步操作。 身份验证过程使用指定的凭据、身份验证选项和通道绑定。
public:
 virtual System::Threading::Tasks::Task ^ AuthenticateAsClientAsync(System::Net::NetworkCredential ^ credential, System::Security::Authentication::ExtendedProtection::ChannelBinding ^ binding, System::String ^ targetName, System::Net::Security::ProtectionLevel requiredProtectionLevel, System::Security::Principal::TokenImpersonationLevel allowedImpersonationLevel);public virtual System.Threading.Tasks.Task AuthenticateAsClientAsync (System.Net.NetworkCredential credential, System.Security.Authentication.ExtendedProtection.ChannelBinding? binding, string targetName, System.Net.Security.ProtectionLevel requiredProtectionLevel, System.Security.Principal.TokenImpersonationLevel allowedImpersonationLevel);public virtual System.Threading.Tasks.Task AuthenticateAsClientAsync (System.Net.NetworkCredential credential, System.Security.Authentication.ExtendedProtection.ChannelBinding binding, string targetName, System.Net.Security.ProtectionLevel requiredProtectionLevel, System.Security.Principal.TokenImpersonationLevel allowedImpersonationLevel);abstract member AuthenticateAsClientAsync : System.Net.NetworkCredential * System.Security.Authentication.ExtendedProtection.ChannelBinding * string * System.Net.Security.ProtectionLevel * System.Security.Principal.TokenImpersonationLevel -> System.Threading.Tasks.Task
override this.AuthenticateAsClientAsync : System.Net.NetworkCredential * System.Security.Authentication.ExtendedProtection.ChannelBinding * string * System.Net.Security.ProtectionLevel * System.Security.Principal.TokenImpersonationLevel -> System.Threading.Tasks.TaskPublic Overridable Function AuthenticateAsClientAsync (credential As NetworkCredential, binding As ChannelBinding, targetName As String, requiredProtectionLevel As ProtectionLevel, allowedImpersonationLevel As TokenImpersonationLevel) As Task参数
- credential
- NetworkCredential
用于确立客户端身份的 NetworkCredential。
- binding
- ChannelBinding
用于扩展保护的 ChannelBinding。
- targetName
- String
唯一标识要进行身份验证的服务器的服务主体名称 (SPN)。
- requiredProtectionLevel
- ProtectionLevel
ProtectionLevel 值之一,指示流的安全服务。
- allowedImpersonationLevel
- TokenImpersonationLevel
TokenImpersonationLevel 值之一,指示服务器使用客户端凭据访问资源的方式。
返回
表示异步操作的任务对象。
例外
              allowedImpersonationLevel 不是有效值。
身份验证失败。 可以使用此对象尝试重新进行身份验证。
身份验证失败。 可以使用此对象尝试重新进行身份验证。
此对象已关闭。
注解
              requiredProtectionLevel使用 参数为使用经过身份验证的流传输的数据请求安全服务。 例如,若要对数据进行加密和签名,请 EncryptAndSign 指定 值。 成功的身份验证不保证已授予请求 ProtectionLevel 。 必须检查 IsEncrypted 和 IsSigned 属性来确定 所使用的NegotiateStream安全服务。
              ChannelBinding在 参数中binding传递给此方法的用于扩展保护的 将由应用程序从TransportContext关联的 SslStream上的 属性检索。
如果身份验证失败,则会收到 AuthenticationException 或 InvalidCredentialException。 在这种情况下,可以使用其他凭据重试身份验证。
此方法存储在任务中,它返回该方法的同步对应项可能引发的所有非使用异常。 如果异常存储在返回的任务中,则在等待任务时将引发该异常。 使用异常(如 ArgumentException)仍会同步引发。 有关存储的异常,请参阅 引发的 AuthenticateAsClient(NetworkCredential, ChannelBinding, String, ProtectionLevel, TokenImpersonationLevel)异常。