NegotiateStream.AuthenticateAsServer 方法

定義

處理用戶端與伺服器連接之驗證的伺服器端。

多載

AuthenticateAsServer(NetworkCredential, ExtendedProtectionPolicy, ProtectionLevel, TokenImpersonationLevel)

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

AuthenticateAsServer(NetworkCredential, ProtectionLevel, TokenImpersonationLevel)

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

AuthenticateAsServer()

由伺服器呼叫以驗證用戶端與伺服器連接中的用戶端,並選擇性地驗證伺服器。

AuthenticateAsServer(ExtendedProtectionPolicy)

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

備註

這些方法會在驗證進行時封鎖。 若要防止應用程式在等候驗證完成時封鎖,請使用 BeginAuthenticateAsServer 方法。

AuthenticateAsServer(NetworkCredential, ExtendedProtectionPolicy, ProtectionLevel, TokenImpersonationLevel)

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

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

public:
 virtual void AuthenticateAsServer(System::Net::NetworkCredential ^ credential, System::Security::Authentication::ExtendedProtection::ExtendedProtectionPolicy ^ policy, System::Net::Security::ProtectionLevel requiredProtectionLevel, System::Security::Principal::TokenImpersonationLevel requiredImpersonationLevel);
public virtual void AuthenticateAsServer (System.Net.NetworkCredential credential, System.Security.Authentication.ExtendedProtection.ExtendedProtectionPolicy? policy, System.Net.Security.ProtectionLevel requiredProtectionLevel, System.Security.Principal.TokenImpersonationLevel requiredImpersonationLevel);
public virtual void AuthenticateAsServer (System.Net.NetworkCredential credential, System.Security.Authentication.ExtendedProtection.ExtendedProtectionPolicy policy, System.Net.Security.ProtectionLevel requiredProtectionLevel, System.Security.Principal.TokenImpersonationLevel requiredImpersonationLevel);
abstract member AuthenticateAsServer : System.Net.NetworkCredential * System.Security.Authentication.ExtendedProtection.ExtendedProtectionPolicy * System.Net.Security.ProtectionLevel * System.Security.Principal.TokenImpersonationLevel -> unit
override this.AuthenticateAsServer : System.Net.NetworkCredential * System.Security.Authentication.ExtendedProtection.ExtendedProtectionPolicy * System.Net.Security.ProtectionLevel * System.Security.Principal.TokenImpersonationLevel -> unit
Public Overridable Sub AuthenticateAsServer (credential As NetworkCredential, policy As ExtendedProtectionPolicy, requiredProtectionLevel As ProtectionLevel, requiredImpersonationLevel As TokenImpersonationLevel)

參數

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檢查 屬性,以判斷是否發生相互驗證。

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

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

另請參閱

適用於

AuthenticateAsServer(NetworkCredential, ProtectionLevel, TokenImpersonationLevel)

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

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

public:
 virtual void AuthenticateAsServer(System::Net::NetworkCredential ^ credential, System::Net::Security::ProtectionLevel requiredProtectionLevel, System::Security::Principal::TokenImpersonationLevel requiredImpersonationLevel);
public virtual void AuthenticateAsServer (System.Net.NetworkCredential credential, System.Net.Security.ProtectionLevel requiredProtectionLevel, System.Security.Principal.TokenImpersonationLevel requiredImpersonationLevel);
abstract member AuthenticateAsServer : System.Net.NetworkCredential * System.Net.Security.ProtectionLevel * System.Security.Principal.TokenImpersonationLevel -> unit
override this.AuthenticateAsServer : System.Net.NetworkCredential * System.Net.Security.ProtectionLevel * System.Security.Principal.TokenImpersonationLevel -> unit
Public Overridable Sub AuthenticateAsServer (credential As NetworkCredential, requiredProtectionLevel As ProtectionLevel, requiredImpersonationLevel As TokenImpersonationLevel)

參數

credential
NetworkCredential

建立伺服器識別所用的 NetworkCredential

requiredProtectionLevel
ProtectionLevel

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

requiredImpersonationLevel
TokenImpersonationLevel

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

例外狀況

credentialnull

requiredImpersonationLevel 必須是 IdentificationImpersonationDelegation

驗證失敗。 您可以使用這個物件嘗試再次驗證。

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

此物件已關閉。

已經進行驗證。

-或-

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

不支援 Windows 95 和 Windows 98。

備註

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

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

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

適用於

AuthenticateAsServer()

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

由伺服器呼叫以驗證用戶端與伺服器連接中的用戶端,並選擇性地驗證伺服器。

public:
 virtual void AuthenticateAsServer();
public virtual void AuthenticateAsServer ();
abstract member AuthenticateAsServer : unit -> unit
override this.AuthenticateAsServer : unit -> unit
Public Overridable Sub AuthenticateAsServer ()

例外狀況

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

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

此物件已關閉。

不支援 Windows 95 和 Windows 98。

備註

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

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

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

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

適用於

AuthenticateAsServer(ExtendedProtectionPolicy)

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

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

public:
 virtual void AuthenticateAsServer(System::Security::Authentication::ExtendedProtection::ExtendedProtectionPolicy ^ policy);
public virtual void AuthenticateAsServer (System.Security.Authentication.ExtendedProtection.ExtendedProtectionPolicy? policy);
public virtual void AuthenticateAsServer (System.Security.Authentication.ExtendedProtection.ExtendedProtectionPolicy policy);
abstract member AuthenticateAsServer : System.Security.Authentication.ExtendedProtection.ExtendedProtectionPolicy -> unit
override this.AuthenticateAsServer : System.Security.Authentication.ExtendedProtection.ExtendedProtectionPolicy -> unit
Public Overridable Sub AuthenticateAsServer (policy As ExtendedProtectionPolicy)

參數

policy
ExtendedProtectionPolicy

用於延伸保護的 ExtendedProtectionPolicy

例外狀況

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

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

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

此物件已關閉。

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

不支援 Windows 95 和 Windows 98。

備註

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

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

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

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

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

另請參閱

適用於