ClientWindowsAuthenticationMembershipProvider.ValidateUser 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
使用作業系統所提供的識別自動驗證目前使用者。
public:
override bool ValidateUser(System::String ^ username, System::String ^ password);
public override bool ValidateUser (string username, string password);
override this.ValidateUser : string * string -> bool
Public Overrides Function ValidateUser (username As String, password As String) As Boolean
參數
傳回
一定是 true
。
例外狀況
範例
下列範例程式碼示範如何使用這個方法來使用 Windows 驗證 來驗證使用者。
private bool ValidateUsingWindowsAuthentication()
{
ClientWindowsAuthenticationMembershipProvider authProvider =
System.Web.Security.Membership.Provider as
ClientWindowsAuthenticationMembershipProvider;
// Call ValidateUser and pass null values for the parameters.
// This call always returns true.
return authProvider.ValidateUser(null, null);
}
Private Function ValidateUsingWindowsAuthentication() As Boolean
Dim authProvider As ClientWindowsAuthenticationMembershipProvider = _
CType(System.Web.Security.Membership.Provider, _
ClientWindowsAuthenticationMembershipProvider)
' Call ValidateUser and pass Nothing for the parameters.
' This call always returns true.
Return authProvider.ValidateUser(Nothing, Nothing)
End Function
備註
當您將應用程式設定為使用 ClientWindowsAuthenticationMembershipProvider 類別時, static
Membership.ValidateUser 方法會使用這個方法進行實作。 方法 ClientWindowsAuthenticationMembershipProvider.ValidateUser 會自動驗證目前的使用者,並將 屬性設定 static
Thread.CurrentPrincipal 為 ClientRolePrincipal 包含目前 WindowsIdentity 的 物件。 ClientRoleProvider如果 已為您的應用程式設定 ,您可以使用 ClientRolePrincipal 物件從角色服務擷取使用者角色資訊。
適用於
另請參閱
意見反應
https://aka.ms/ContentUserFeedback。
即將登場:在 2024 年,我們將逐步淘汰 GitHub 問題作為內容的意見反應機制,並將它取代為新的意見反應系統。 如需詳細資訊,請參閱:提交並檢視相關的意見反應