NegotiateStream.BeginAuthenticateAsServer 方法

定義

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

多載

BeginAuthenticateAsServer(NetworkCredential, ExtendedProtectionPolicy, ProtectionLevel, TokenImpersonationLevel, AsyncCallback, Object)

由伺服器呼叫以開始非同步作業,以便驗證用戶端與伺服器連接中的用戶端,並選擇性地驗證伺服器。 驗證處理序使用指定的伺服器認證、驗證選項和延伸保護原則。 這個方法不會封鎖。

BeginAuthenticateAsServer(AsyncCallback, Object)

由伺服器呼叫以開始非同步作業,以便驗證用戶端與伺服器連接中的用戶端,並選擇性地驗證伺服器。 這個方法不會封鎖。

BeginAuthenticateAsServer(ExtendedProtectionPolicy, AsyncCallback, Object)

由伺服器呼叫以開始非同步作業,以便驗證用戶端與伺服器連接中的用戶端,並選擇性地驗證伺服器。 驗證處理序使用指定的延伸保護原則。 這個方法不會封鎖。

BeginAuthenticateAsServer(NetworkCredential, ProtectionLevel, TokenImpersonationLevel, AsyncCallback, Object)

由伺服器呼叫以開始非同步作業,以便驗證用戶端與伺服器連接中的用戶端,並選擇性地驗證伺服器。 驗證處理序使用指定的伺服器認證和驗證選項。 這個方法不會封鎖。

備註

此方法的多載不會在驗證進行時封鎖。 若要在等候驗證完成時封鎖,請使用 AuthenticateAsServer 方法。

BeginAuthenticateAsServer(NetworkCredential, ExtendedProtectionPolicy, ProtectionLevel, TokenImpersonationLevel, AsyncCallback, Object)

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

由伺服器呼叫以開始非同步作業,以便驗證用戶端與伺服器連接中的用戶端,並選擇性地驗證伺服器。 驗證處理序使用指定的伺服器認證、驗證選項和延伸保護原則。 這個方法不會封鎖。

public:
 virtual IAsyncResult ^ BeginAuthenticateAsServer(System::Net::NetworkCredential ^ credential, System::Security::Authentication::ExtendedProtection::ExtendedProtectionPolicy ^ policy, System::Net::Security::ProtectionLevel requiredProtectionLevel, System::Security::Principal::TokenImpersonationLevel requiredImpersonationLevel, AsyncCallback ^ asyncCallback, System::Object ^ asyncState);
public virtual IAsyncResult BeginAuthenticateAsServer (System.Net.NetworkCredential credential, System.Security.Authentication.ExtendedProtection.ExtendedProtectionPolicy? policy, System.Net.Security.ProtectionLevel requiredProtectionLevel, System.Security.Principal.TokenImpersonationLevel requiredImpersonationLevel, AsyncCallback? asyncCallback, object? asyncState);
public virtual IAsyncResult BeginAuthenticateAsServer (System.Net.NetworkCredential credential, System.Security.Authentication.ExtendedProtection.ExtendedProtectionPolicy policy, System.Net.Security.ProtectionLevel requiredProtectionLevel, System.Security.Principal.TokenImpersonationLevel requiredImpersonationLevel, AsyncCallback asyncCallback, object asyncState);
abstract member BeginAuthenticateAsServer : System.Net.NetworkCredential * System.Security.Authentication.ExtendedProtection.ExtendedProtectionPolicy * System.Net.Security.ProtectionLevel * System.Security.Principal.TokenImpersonationLevel * AsyncCallback * obj -> IAsyncResult
override this.BeginAuthenticateAsServer : System.Net.NetworkCredential * System.Security.Authentication.ExtendedProtection.ExtendedProtectionPolicy * System.Net.Security.ProtectionLevel * System.Security.Principal.TokenImpersonationLevel * AsyncCallback * obj -> IAsyncResult
Public Overridable Function BeginAuthenticateAsServer (credential As NetworkCredential, policy As ExtendedProtectionPolicy, requiredProtectionLevel As ProtectionLevel, requiredImpersonationLevel As TokenImpersonationLevel, asyncCallback As AsyncCallback, asyncState As Object) As IAsyncResult

參數

credential
NetworkCredential

建立用戶端識別所用的 NetworkCredential

policy
ExtendedProtectionPolicy

用於延伸保護的 ExtendedProtectionPolicy

requiredProtectionLevel
ProtectionLevel

其中一個 ProtectionLevel 值,表示資料流的安全性服務。

requiredImpersonationLevel
TokenImpersonationLevel

其中一個 TokenImpersonationLevel 值,表示伺服器要如何使用用戶端的認證來存取資源。

asyncCallback
AsyncCallback

AsyncCallback 委派,會於驗證完成時參考要叫用的方法。

asyncState
Object

包含寫入作業資訊的使用者定義物件。 作業完成時會將這個物件傳遞給 asyncCallback 委派。

傳回

IAsyncResult 物件,指出非同步作業的狀態。

例外狀況

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

credentialnull

requiredImpersonationLevel 必須是 IdentificationImpersonationDelegation

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

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

已經進行驗證。

-或-

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

此物件已關閉。

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

不支援 Windows 95 和 Windows 98。

備註

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

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

這個方法是異步的,而且不會在作業完成時封鎖。 若要封鎖直到作業完成為止,請使用其中 AuthenticateAsServer 一個方法多載。

呼叫 方法必須完成 EndAuthenticateAsServer 異步驗證作業。 一般而言,委派會叫 asyncCallback 用 方法。 如需使用異步程序設計模型的詳細資訊,請參閱 以異步方式呼叫同步方法

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

另請參閱

適用於

BeginAuthenticateAsServer(AsyncCallback, Object)

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

由伺服器呼叫以開始非同步作業,以便驗證用戶端與伺服器連接中的用戶端,並選擇性地驗證伺服器。 這個方法不會封鎖。

public:
 virtual IAsyncResult ^ BeginAuthenticateAsServer(AsyncCallback ^ asyncCallback, System::Object ^ asyncState);
public virtual IAsyncResult BeginAuthenticateAsServer (AsyncCallback? asyncCallback, object? asyncState);
public virtual IAsyncResult BeginAuthenticateAsServer (AsyncCallback asyncCallback, object asyncState);
abstract member BeginAuthenticateAsServer : AsyncCallback * obj -> IAsyncResult
override this.BeginAuthenticateAsServer : AsyncCallback * obj -> IAsyncResult
Public Overridable Function BeginAuthenticateAsServer (asyncCallback As AsyncCallback, asyncState As Object) As IAsyncResult

參數

asyncCallback
AsyncCallback

AsyncCallback 委派,會於驗證完成時參考要叫用的方法。

asyncState
Object

包含作業資訊的使用者定義物件。 作業完成時會將這個物件傳遞給 asyncCallback 委派。

傳回

IAsyncResult 物件,指出非同步作業的狀態。

例外狀況

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

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

此物件已關閉。

不支援 Windows 95 和 Windows 98。

備註

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

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

若要封鎖直到作業完成為止,請使用其中 AuthenticateAsServer 一個方法多載。

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

適用於

BeginAuthenticateAsServer(ExtendedProtectionPolicy, AsyncCallback, Object)

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

由伺服器呼叫以開始非同步作業,以便驗證用戶端與伺服器連接中的用戶端,並選擇性地驗證伺服器。 驗證處理序使用指定的延伸保護原則。 這個方法不會封鎖。

public:
 virtual IAsyncResult ^ BeginAuthenticateAsServer(System::Security::Authentication::ExtendedProtection::ExtendedProtectionPolicy ^ policy, AsyncCallback ^ asyncCallback, System::Object ^ asyncState);
public virtual IAsyncResult BeginAuthenticateAsServer (System.Security.Authentication.ExtendedProtection.ExtendedProtectionPolicy? policy, AsyncCallback? asyncCallback, object? asyncState);
public virtual IAsyncResult BeginAuthenticateAsServer (System.Security.Authentication.ExtendedProtection.ExtendedProtectionPolicy policy, AsyncCallback asyncCallback, object asyncState);
abstract member BeginAuthenticateAsServer : System.Security.Authentication.ExtendedProtection.ExtendedProtectionPolicy * AsyncCallback * obj -> IAsyncResult
override this.BeginAuthenticateAsServer : System.Security.Authentication.ExtendedProtection.ExtendedProtectionPolicy * AsyncCallback * obj -> IAsyncResult
Public Overridable Function BeginAuthenticateAsServer (policy As ExtendedProtectionPolicy, asyncCallback As AsyncCallback, asyncState As Object) As IAsyncResult

參數

policy
ExtendedProtectionPolicy

用於延伸保護的 ExtendedProtectionPolicy

asyncCallback
AsyncCallback

AsyncCallback 委派,會於驗證完成時參考要叫用的方法。

asyncState
Object

包含寫入作業資訊的使用者定義物件。 作業完成時會將這個物件傳遞給 asyncCallback 委派。

傳回

IAsyncResult 物件,指出非同步作業的狀態。

例外狀況

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

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

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

此物件已關閉。

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

不支援 Windows 95 和 Windows 98。

備註

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

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

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

若要封鎖直到作業完成為止,請使用其中 AuthenticateAsServer 一個方法多載。

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

另請參閱

適用於

BeginAuthenticateAsServer(NetworkCredential, ProtectionLevel, TokenImpersonationLevel, AsyncCallback, Object)

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

由伺服器呼叫以開始非同步作業,以便驗證用戶端與伺服器連接中的用戶端,並選擇性地驗證伺服器。 驗證處理序使用指定的伺服器認證和驗證選項。 這個方法不會封鎖。

public:
 virtual IAsyncResult ^ BeginAuthenticateAsServer(System::Net::NetworkCredential ^ credential, System::Net::Security::ProtectionLevel requiredProtectionLevel, System::Security::Principal::TokenImpersonationLevel requiredImpersonationLevel, AsyncCallback ^ asyncCallback, System::Object ^ asyncState);
public virtual IAsyncResult BeginAuthenticateAsServer (System.Net.NetworkCredential credential, System.Net.Security.ProtectionLevel requiredProtectionLevel, System.Security.Principal.TokenImpersonationLevel requiredImpersonationLevel, AsyncCallback? asyncCallback, object? asyncState);
public virtual IAsyncResult BeginAuthenticateAsServer (System.Net.NetworkCredential credential, System.Net.Security.ProtectionLevel requiredProtectionLevel, System.Security.Principal.TokenImpersonationLevel requiredImpersonationLevel, AsyncCallback asyncCallback, object asyncState);
abstract member BeginAuthenticateAsServer : System.Net.NetworkCredential * System.Net.Security.ProtectionLevel * System.Security.Principal.TokenImpersonationLevel * AsyncCallback * obj -> IAsyncResult
override this.BeginAuthenticateAsServer : System.Net.NetworkCredential * System.Net.Security.ProtectionLevel * System.Security.Principal.TokenImpersonationLevel * AsyncCallback * obj -> IAsyncResult
Public Overridable Function BeginAuthenticateAsServer (credential As NetworkCredential, requiredProtectionLevel As ProtectionLevel, requiredImpersonationLevel As TokenImpersonationLevel, asyncCallback As AsyncCallback, asyncState As Object) As IAsyncResult

參數

credential
NetworkCredential

建立用戶端識別所用的 NetworkCredential

requiredProtectionLevel
ProtectionLevel

其中一個 ProtectionLevel 值,表示資料流的安全性服務。

requiredImpersonationLevel
TokenImpersonationLevel

其中一個 TokenImpersonationLevel 值,表示伺服器要如何使用用戶端的認證來存取資源。

asyncCallback
AsyncCallback

AsyncCallback 委派,會於驗證完成時參考要叫用的方法。

asyncState
Object

包含作業資訊的使用者定義物件。 作業完成時會將這個物件傳遞給 asyncCallback 委派。

傳回

IAsyncResult 物件,指出非同步作業的狀態。

例外狀況

credentialnull

requiredImpersonationLevel 必須是 IdentificationImpersonationDelegation

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

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

此物件已關閉。

已經進行驗證。

-或-

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

不支援 Windows 95 和 Windows 98。

備註

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

這個方法是異步的,而且不會在作業完成時封鎖。 若要封鎖直到作業完成為止,請使用其中 AuthenticateAsServer 一個方法多載。

呼叫 方法必須完成 EndAuthenticateAsServer 異步驗證作業。 一般而言,委派會叫 asyncCallback 用 方法。 如需使用異步程序設計模型的詳細資訊,請參閱 以異步方式呼叫同步方法

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

適用於