NegotiateStream.AuthenticateAsServerAsync 方法

定義

以非同步作業方式處理驗證用戶端與伺服器連接的伺服器端。

多載

AuthenticateAsServerAsync()

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

AuthenticateAsServerAsync(ExtendedProtectionPolicy)

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

AuthenticateAsServerAsync(NetworkCredential, ProtectionLevel, TokenImpersonationLevel)

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

AuthenticateAsServerAsync(NetworkCredential, ExtendedProtectionPolicy, ProtectionLevel, TokenImpersonationLevel)

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

AuthenticateAsServerAsync()

來源:
NegotiateStream.cs
來源:
NegotiateStream.cs
來源:
NegotiateStream.cs

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

public:
 virtual System::Threading::Tasks::Task ^ AuthenticateAsServerAsync();
public virtual System.Threading.Tasks.Task AuthenticateAsServerAsync ();
abstract member AuthenticateAsServerAsync : unit -> System.Threading.Tasks.Task
override this.AuthenticateAsServerAsync : unit -> System.Threading.Tasks.Task
Public Overridable Function AuthenticateAsServerAsync () As Task

傳回

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

例外狀況

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

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

此物件已關閉。

不支援 Windows 95 和 Windows 98。

備註

驗證會使用伺服器的 DefaultCredentials。 未為伺服器指定任何服務主體名稱 (SPN) 。 模擬層級為 Identification,且安全性層級為 EncryptAndSign

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

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

這個方法會儲存在工作中,它會傳回方法同步對應專案可以擲回的所有非使用例外狀況。 如果例外狀況儲存在傳回的工作中,則會在等候工作時擲回該例外狀況。 使用例外狀況,例如 ArgumentException仍會同步擲回。 如需預存例外狀況,請參閱 擲回的 AuthenticateAsServer()例外狀況。

適用於

AuthenticateAsServerAsync(ExtendedProtectionPolicy)

來源:
NegotiateStream.cs
來源:
NegotiateStream.cs
來源:
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);
public virtual System.Threading.Tasks.Task AuthenticateAsServerAsync (System.Security.Authentication.ExtendedProtection.ExtendedProtectionPolicy policy);
abstract member AuthenticateAsServerAsync : System.Security.Authentication.ExtendedProtection.ExtendedProtectionPolicy -> System.Threading.Tasks.Task
override this.AuthenticateAsServerAsync : System.Security.Authentication.ExtendedProtection.ExtendedProtectionPolicy -> System.Threading.Tasks.Task
Public Overridable Function AuthenticateAsServerAsync (policy As ExtendedProtectionPolicy) As Task

參數

policy
ExtendedProtectionPolicy

用於延伸保護的 ExtendedProtectionPolicy

傳回

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

例外狀況

根據延伸保護原則傳入 policy 參數中的 CustomChannelBindingCustomServiceNames 都是 null

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

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

此物件已關閉。

在不支援延伸保護的平台上,policy 參數設定為 Always

不支援 Windows 95 和 Windows 98。

備註

驗證會使用伺服器的 DefaultCredentials。 未為伺服器指定任何服務主體名稱 (SPN) 。 模擬層級為 Identification,且安全性層級為 EncryptAndSign

policy如果 參數為 null,則會使用已PolicyEnforcement設定為Never的擴充保護原則。

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

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

這個方法會儲存在工作中,它會傳回方法同步對應專案可以擲回的所有非使用例外狀況。 如果例外狀況儲存在傳回的工作中,則會在等候工作時擲回該例外狀況。 使用例外狀況,例如 ArgumentException仍會同步擲回。 如需預存例外狀況,請參閱 擲回的 AuthenticateAsServer(ExtendedProtectionPolicy)例外狀況。

另請參閱

適用於

AuthenticateAsServerAsync(NetworkCredential, ProtectionLevel, TokenImpersonationLevel)

來源:
NegotiateStream.cs
來源:
NegotiateStream.cs
來源:
NegotiateStream.cs

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

public:
 virtual System::Threading::Tasks::Task ^ AuthenticateAsServerAsync(System::Net::NetworkCredential ^ credential, System::Net::Security::ProtectionLevel requiredProtectionLevel, System::Security::Principal::TokenImpersonationLevel requiredImpersonationLevel);
public virtual System.Threading.Tasks.Task AuthenticateAsServerAsync (System.Net.NetworkCredential credential, System.Net.Security.ProtectionLevel requiredProtectionLevel, System.Security.Principal.TokenImpersonationLevel requiredImpersonationLevel);
abstract member AuthenticateAsServerAsync : System.Net.NetworkCredential * System.Net.Security.ProtectionLevel * System.Security.Principal.TokenImpersonationLevel -> System.Threading.Tasks.Task
override this.AuthenticateAsServerAsync : System.Net.NetworkCredential * System.Net.Security.ProtectionLevel * System.Security.Principal.TokenImpersonationLevel -> System.Threading.Tasks.Task
Public Overridable Function AuthenticateAsServerAsync (credential As NetworkCredential, requiredProtectionLevel As ProtectionLevel, requiredImpersonationLevel As TokenImpersonationLevel) As Task

參數

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)例外狀況。

適用於

AuthenticateAsServerAsync(NetworkCredential, ExtendedProtectionPolicy, ProtectionLevel, TokenImpersonationLevel)

來源:
NegotiateStream.cs
來源:
NegotiateStream.cs
來源:
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);
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);
abstract member AuthenticateAsServerAsync : System.Net.NetworkCredential * System.Security.Authentication.ExtendedProtection.ExtendedProtectionPolicy * System.Net.Security.ProtectionLevel * System.Security.Principal.TokenImpersonationLevel -> System.Threading.Tasks.Task
override this.AuthenticateAsServerAsync : System.Net.NetworkCredential * System.Security.Authentication.ExtendedProtection.ExtendedProtectionPolicy * System.Net.Security.ProtectionLevel * System.Security.Principal.TokenImpersonationLevel -> System.Threading.Tasks.Task
Public Overridable Function AuthenticateAsServerAsync (credential As NetworkCredential, policy As ExtendedProtectionPolicy, requiredProtectionLevel As ProtectionLevel, requiredImpersonationLevel As TokenImpersonationLevel) As Task

參數

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,則會使用已PolicyEnforcement設定為Never的擴充保護原則。

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

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

這個方法會儲存在工作中,它會傳回方法同步對應專案可以擲回的所有非使用狀況例外狀況。 如果例外狀況儲存在傳回的工作中,則會在等候工作時擲回該例外狀況。 使用狀況例外狀況,例如 ArgumentException,仍會同步擲回。 如需預存的例外狀況,請參閱 所 AuthenticateAsServer(NetworkCredential, ExtendedProtectionPolicy, ProtectionLevel, TokenImpersonationLevel)擲回的例外狀況。

另請參閱

適用於