ClientWindowsAuthenticationMembershipProvider 類別

定義

以用戶端應用程式服務啟用 Windows 驗證。

public ref class ClientWindowsAuthenticationMembershipProvider : System::Web::Security::MembershipProvider
public class ClientWindowsAuthenticationMembershipProvider : System.Web.Security.MembershipProvider
type ClientWindowsAuthenticationMembershipProvider = class
    inherit MembershipProvider
Public Class ClientWindowsAuthenticationMembershipProvider
Inherits MembershipProvider
繼承
ClientWindowsAuthenticationMembershipProvider

範例

下列範例程式碼示範如何使用這個方法來使用 Windows 驗證 來驗證使用者。 在此範例中 staticMembership.Provider ,屬性的值會轉換成 ClientWindowsAuthenticationMembershipProvider 實例。 這可確保 NullReferenceException 如果您不小心使用其他成員資格提供者來測試此程式碼,將會擲回 。

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

備註

您可以使用用戶端應用程式服務,使用Windows 驗證來驗證使用者。 若要啟用Windows 驗證,請將應用程式設定為使用 ClientWindowsAuthenticationMembershipProvider 類別。

設定之後,您可以呼叫 staticMembership.ValidateUser 方法來驗證使用者。 方法 Membership.ValidateUser 會在內部呼叫 ValidateUser 方法。

方法 ClientWindowsAuthenticationMembershipProvider.ValidateUser 會自動驗證目前的使用者,並將 屬性設定 staticThread.CurrentPrincipalClientRolePrincipal 包含目前 WindowsIdentity 的 物件。 ClientRoleProvider如果 已為您的應用程式設定 ,您可以使用 ClientRolePrincipal 物件從角色服務擷取使用者角色資訊。

您可以透過 屬性擷取目前 ClientWindowsAuthenticationMembershipProvider 實例的 staticMembership.Provider 參考。 您可以使用成員資格提供者參考直接呼叫 ClientWindowsAuthenticationMembershipProvider.ValidateUser 方法。 此外,您將需要成員資格提供者參考來呼叫 Logout 方法,這在基類中 MembershipProvider 無法使用。

建構函式

ClientWindowsAuthenticationMembershipProvider()

初始化 ClientWindowsAuthenticationMembershipProvider 類別的新執行個體。

屬性

ApplicationName

這個屬性不是由這個類別所使用。

Description

取得簡短、易讀的描述,適合顯示在管理工具或其他使用者介面 (UI) 中。

(繼承來源 ProviderBase)
EnablePasswordReset

這個屬性不是由這個類別所使用。

EnablePasswordRetrieval

這個屬性不是由這個類別所使用。

MaxInvalidPasswordAttempts

這個屬性不是由這個類別所使用。

MinRequiredNonAlphanumericCharacters

這個屬性不是由這個類別所使用。

MinRequiredPasswordLength

這個屬性不是由這個類別所使用。

Name

取得用來在設定期間代表提供者的易記名稱。

(繼承來源 ProviderBase)
PasswordAttemptWindow

這個屬性不是由這個類別所使用。

PasswordFormat

這個屬性不是由這個類別所使用。

PasswordStrengthRegularExpression

這個屬性不是由這個類別所使用。

RequiresQuestionAndAnswer

這個屬性不是由這個類別所使用。

RequiresUniqueEmail

這個屬性不是由這個類別所使用。

方法

ChangePassword(String, String, String)

這個類別不會使用這個方法。

ChangePasswordQuestionAndAnswer(String, String, String, String)

這個類別不會使用這個方法。

CreateUser(String, String, String, String, String, Boolean, Object, MembershipCreateStatus)

這個類別不會使用這個方法。

DecryptPassword(Byte[])

解密加密的密碼。

(繼承來源 MembershipProvider)
DeleteUser(String, Boolean)

這個類別不會使用這個方法。

EncryptPassword(Byte[])

將密碼加密。

(繼承來源 MembershipProvider)
EncryptPassword(Byte[], MembershipPasswordCompatibilityMode)

使用指定的密碼相容模式,加密指定的密碼。

(繼承來源 MembershipProvider)
Equals(Object)

判斷指定的物件是否等於目前的物件。

(繼承來源 Object)
FindUsersByEmail(String, Int32, Int32, Int32)

這個類別不會使用這個方法。

FindUsersByName(String, Int32, Int32, Int32)

這個類別不會使用這個方法。

GetAllUsers(Int32, Int32, Int32)

這個類別不會使用這個方法。

GetHashCode()

做為預設雜湊函式。

(繼承來源 Object)
GetNumberOfUsersOnline()

這個類別不會使用這個方法。

GetPassword(String, String)

這個類別不會使用這個方法。

GetType()

取得目前執行個體的 Type

(繼承來源 Object)
GetUser(Object, Boolean)

這個類別不會使用這個方法。

GetUser(String, Boolean)

這個類別不會使用這個方法。

GetUserNameByEmail(String)

這個類別不會使用這個方法。

Initialize(String, NameValueCollection)

初始化設定產生器。

(繼承來源 ProviderBase)
Logout()

登出使用者。

MemberwiseClone()

建立目前 Object 的淺層複製。

(繼承來源 Object)
OnValidatingPassword(ValidatePasswordEventArgs)

如果已定義事件處理常式,則引發 ValidatingPassword 事件。

(繼承來源 MembershipProvider)
ResetPassword(String, String)

這個類別不會使用這個方法。

ToString()

傳回代表目前物件的字串。

(繼承來源 Object)
UnlockUser(String)

這個類別不會使用這個方法。

UpdateUser(MembershipUser)

這個類別不會使用這個方法。

ValidateUser(String, String)

使用作業系統所提供的識別自動驗證目前使用者。

事件

ValidatingPassword

當建立使用者、變更密碼或重設密碼時發生。

(繼承來源 MembershipProvider)

適用於

另請參閱