NegotiateStream.AuthenticateAsClientAsync 方法

定義

由用戶端呼叫做為非同步作業,以驗證用戶端與伺服器連接中的用戶端,並選擇性地驗證伺服器。

多載

AuthenticateAsClientAsync()

由用戶端呼叫做為非同步作業,以驗證用戶端與伺服器連接中的用戶端,並選擇性地驗證伺服器。

AuthenticateAsClientAsync(NetworkCredential, String)

由用戶端呼叫做為非同步作業,以驗證用戶端與伺服器連接中的用戶端,並選擇性地驗證伺服器。 驗證處理序使用指定的用戶端認證。

AuthenticateAsClientAsync(NetworkCredential, ChannelBinding, String)

由用戶端呼叫做為非同步作業,以驗證用戶端與伺服器連接中的用戶端,並選擇性地驗證伺服器。 驗證處理序使用指定的用戶端認證和通道繫結。

AuthenticateAsClientAsync(NetworkCredential, String, ProtectionLevel, TokenImpersonationLevel)

由用戶端呼叫做為非同步作業,以驗證用戶端與伺服器連接中的用戶端,並選擇性地驗證伺服器。 驗證處理序使用指定的認證和驗證選項。

AuthenticateAsClientAsync(NetworkCredential, ChannelBinding, String, ProtectionLevel, TokenImpersonationLevel)

由用戶端呼叫做為非同步作業,以驗證用戶端與伺服器連接中的用戶端,並選擇性地驗證伺服器。 驗證處理序使用指定的認證、驗證選項和通道繫結。

AuthenticateAsClientAsync()

由用戶端呼叫做為非同步作業,以驗證用戶端與伺服器連接中的用戶端,並選擇性地驗證伺服器。

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.Task
Public Overridable Function AuthenticateAsClientAsync () As Task

傳回

Task

工作物件,表示非同步作業。

例外狀況

驗證失敗。 您可以使用這個物件重試驗證。

驗證失敗。 您可以使用這個物件重試驗證。

此物件已關閉。

已經進行驗證。

-或-

這個資料流先前是用來以伺服器的身分嘗試驗證。 您不能使用資料流以用戶端身分重試驗證。

備註

驗證會使用用戶端 的 DefaultCredentials 。 未為伺服器指定任何服務主體名稱 (SPN) 。 模擬層級為 Identification ,安全性層級為 EncryptAndSign ,而且會要求相互驗證。 類別 NegotiateStream 會建構用於相互驗證的 SPN。

驗證成功時,您必須檢查 IsEncryptedIsSigned 屬性,以判斷 所使用的 NegotiateStream 安全性服務。 IsMutuallyAuthenticated檢查 屬性,以判斷是否發生相互驗證。

如果驗證失敗,您會收到 AuthenticationExceptionInvalidCredentialException 。 在此情況下,您可以使用不同的認證重試驗證。

適用於

AuthenticateAsClientAsync(NetworkCredential, String)

由用戶端呼叫做為非同步作業,以驗證用戶端與伺服器連接中的用戶端,並選擇性地驗證伺服器。 驗證處理序使用指定的用戶端認證。

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.Task
Public Overridable Function AuthenticateAsClientAsync (credential As NetworkCredential, targetName As String) As Task

參數

credential
NetworkCredential

建立用戶端識別所用的 NetworkCredential

targetName
String

服務主要名稱 (SPN),用來唯一識別要驗證的伺服器。

傳回

Task

工作物件,表示非同步作業。

例外狀況

驗證失敗。 您可以使用這個物件重試驗證。

驗證失敗。 您可以使用這個物件重試驗證。

此物件已關閉。

已經進行驗證。

-或-

這個資料流先前是用來以伺服器的身分嘗試驗證。 您不能使用資料流以用戶端身分重試驗證。

targetNamenull

備註

模擬層級為 Identification ,安全性層級為 EncryptAndSign ,而且會要求相互驗證。 類別 NegotiateStream 會建構用於相互驗證的 SPN。

驗證成功時,您必須檢查 IsEncryptedIsSigned 屬性,以判斷 所使用的 NegotiateStream 安全性服務。 IsMutuallyAuthenticated檢查 屬性,以判斷是否發生相互驗證。

適用於

AuthenticateAsClientAsync(NetworkCredential, ChannelBinding, String)

由用戶端呼叫做為非同步作業,以驗證用戶端與伺服器連接中的用戶端,並選擇性地驗證伺服器。 驗證處理序使用指定的用戶端認證和通道繫結。

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.Task
Public Overridable Function AuthenticateAsClientAsync (credential As NetworkCredential, binding As ChannelBinding, targetName As String) As Task

參數

credential
NetworkCredential

建立用戶端識別所用的 NetworkCredential

binding
ChannelBinding

用於延伸保護的 ChannelBinding

targetName
String

服務主要名稱 (SPN),用來唯一識別要驗證的伺服器。

傳回

Task

工作物件,表示非同步作業。

例外狀況

targetNamenull

-或- credentialnull

驗證失敗。 您可以使用這個物件重試驗證。

驗證失敗。 您可以使用這個物件重試驗證。

已經進行驗證。

-或-

這個資料流先前是用來以伺服器的身分嘗試驗證。 您不能使用資料流以用戶端身分重試驗證。

此物件已關閉。

備註

模擬層級為 Identification ,安全性層級為 EncryptAndSign ,而且會要求相互驗證。 類別 NegotiateStream 會建構用於相互驗證的 SPN。

ChannelBinding用於在 參數中傳遞至這個方法之擴充保護的 binding ,會由應用程式從 TransportContext 相關聯 SslStream 上的 屬性擷取。

驗證成功時,您必須檢查 IsEncryptedIsSigned 屬性,以判斷 所使用的 NegotiateStream 安全性服務。 IsMutuallyAuthenticated檢查 屬性,以判斷是否發生相互驗證。

另請參閱

適用於

AuthenticateAsClientAsync(NetworkCredential, String, ProtectionLevel, TokenImpersonationLevel)

由用戶端呼叫做為非同步作業,以驗證用戶端與伺服器連接中的用戶端,並選擇性地驗證伺服器。 驗證處理序使用指定的認證和驗證選項。

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.Task
Public 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 值,表示伺服器要如何使用用戶端的認證來存取資源。

傳回

Task

工作物件,表示非同步作業。

例外狀況

allowedImpersonationLevel 不是有效的值。

targetName 為 null。

驗證失敗。 您可以使用這個物件重試驗證。

驗證失敗。 您可以使用這個物件重試驗證。

此物件已關閉。

已經進行驗證。

-或-

這個資料流先前是用來以伺服器的身分嘗試驗證。 您不能使用資料流以用戶端身分重試驗證。

備註

requiredProtectionLevel使用 參數來要求使用已驗證資料流程傳輸之資料的安全性服務。 例如,若要讓資料加密並簽署,請 EncryptAndSign 指定 值。 成功的驗證不保證已授與所要求的 ProtectionLevel 。 您必須檢查 IsEncryptedIsSigned 屬性,以判斷 所使用的 NegotiateStream 安全性服務。

如果驗證失敗,您會收到 AuthenticationExceptionInvalidCredentialException 。 在此情況下,您可以使用不同的認證重試驗證。

適用於

AuthenticateAsClientAsync(NetworkCredential, ChannelBinding, String, ProtectionLevel, TokenImpersonationLevel)

由用戶端呼叫做為非同步作業,以驗證用戶端與伺服器連接中的用戶端,並選擇性地驗證伺服器。 驗證處理序使用指定的認證、驗證選項和通道繫結。

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.Task
Public 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 值,表示伺服器要如何使用用戶端的認證來存取資源。

傳回

Task

工作物件,表示非同步作業。

例外狀況

targetNamenull

-或- credentialnull

allowedImpersonationLevel 不是有效的值。

驗證失敗。 您可以使用這個物件重試驗證。

驗證失敗。 您可以使用這個物件重試驗證。

已經進行驗證。

-或-

這個資料流先前是用來以伺服器的身分嘗試驗證。 您不能使用資料流以用戶端身分重試驗證。

此物件已關閉。

備註

requiredProtectionLevel使用 參數來要求使用已驗證資料流程傳輸之資料的安全性服務。 例如,若要讓資料加密並簽署,請 EncryptAndSign 指定 值。 成功的驗證不保證已授與所要求的 ProtectionLevel 。 您必須檢查 IsEncryptedIsSigned 屬性,以判斷 所使用的 NegotiateStream 安全性服務。

ChannelBinding用於在 參數中 binding 傳遞至這個方法的 擴充保護,會由應用程式從 TransportContext 相關聯 SslStream 上的 屬性擷取。

如果驗證失敗,您會收到 AuthenticationExceptionInvalidCredentialException 。 在此情況下,您可以使用不同的認證重試驗證。

另請參閱

適用於