ClientWindowsAuthenticationMembershipProvider 类

定义

通过客户端应用程序服务实现 Windows 身份验证。Enables Windows authentication with client application services.

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 身份验证对用户进行身份验证。The following example code demonstrates how to use this method to authenticate a user by using Windows authentication. 在此示例中,将static Membership.Provider ClientWindowsAuthenticationMembershipProvider属性的值强制转换为实例。In this example, the value of the static Membership.Provider property is cast to a ClientWindowsAuthenticationMembershipProvider instance. 这可以确保如果你NullReferenceException使用另一个成员资格提供程序意外测试此代码,将引发。This makes sure that a NullReferenceException will be thrown if you accidentally test this code by using another membership provider.

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 身份验证来验证用户。You can use client application services to validate users by using Windows authentication. 若要启用 Windows 身份验证,请将应用程序配置ClientWindowsAuthenticationMembershipProvider为使用类。To enable Windows authentication, you configure your application to use the ClientWindowsAuthenticationMembershipProvider class. 有关详细信息,请参阅如何:配置客户端应用程序服务For more information, see How to: Configure Client Application Services.

配置后,可以通过调用static Membership.ValidateUser方法来验证用户。After configuration, you can validate users by calling the static Membership.ValidateUser method. 方法在内部ValidateUser调用方法。 Membership.ValidateUserThe Membership.ValidateUser method internally calls the ValidateUser method.

Thread.CurrentPrincipal static WindowsIdentity ClientRolePrincipal方法自动对当前用户进行身份验证,并将属性设置为包含当前的对象。 ClientWindowsAuthenticationMembershipProvider.ValidateUserThe ClientWindowsAuthenticationMembershipProvider.ValidateUser method automatically authenticates the current user and sets the static Thread.CurrentPrincipal property to a ClientRolePrincipal object that contains the current WindowsIdentity. 如果为ClientRoleProvider应用程序配置了,则可以ClientRolePrincipal使用对象从角色服务中检索用户角色信息。If a ClientRoleProvider is configured for your application, you can use the ClientRolePrincipal object to retrieve user role information from the roles service.

您可以ClientWindowsAuthenticationMembershipProvider static 通过属性检索对当前Membership.Provider实例的引用。You can retrieve a reference to the current ClientWindowsAuthenticationMembershipProvider instance through the static Membership.Provider property. 您可以使用成员资格提供程序引用直接调用ClientWindowsAuthenticationMembershipProvider.ValidateUser方法。You can use the membership provider reference to call the ClientWindowsAuthenticationMembershipProvider.ValidateUser method directly. 此外,还需要成员资格提供程序引用来调用Logout方法,该方法MembershipProvider在基类中不可用。Additionally, you will need the membership provider reference to call the Logout method, which is not available in the MembershipProvider base class.

构造函数

ClientWindowsAuthenticationMembershipProvider()

初始化 ClientWindowsAuthenticationMembershipProvider 类的新实例。Initializes a new instance of the ClientWindowsAuthenticationMembershipProvider class.

属性

ApplicationName

此类未使用此属性。This property is not used by this class.

Description

获取一条简短的易懂描述,它适合在管理工具或其他用户界面 (UI) 中显示。Gets a brief, friendly description suitable for display in administrative tools or other user interfaces (UIs).

(继承自 ProviderBase)
EnablePasswordReset

此类未使用此属性。This property is not used by this class.

EnablePasswordRetrieval

此类未使用此属性。This property is not used by this class.

MaxInvalidPasswordAttempts

此类未使用此属性。This property is not used by this class.

MinRequiredNonAlphanumericCharacters

此类未使用此属性。This property is not used by this class.

MinRequiredPasswordLength

此类未使用此属性。This property is not used by this class.

Name

获得一个友好名称,用于在配置过程中引用提供程序。Gets the friendly name used to refer to the provider during configuration.

(继承自 ProviderBase)
PasswordAttemptWindow

此类未使用此属性。This property is not used by this class.

PasswordFormat

此类未使用此属性。This property is not used by this class.

PasswordStrengthRegularExpression

此类未使用此属性。This property is not used by this class.

RequiresQuestionAndAnswer

此类未使用此属性。This property is not used by this class.

RequiresUniqueEmail

此类未使用此属性。This property is not used by this class.

方法

ChangePassword(String, String, String)

此类未使用此方法。This method is not used by this class.

ChangePasswordQuestionAndAnswer(String, String, String, String)

此类未使用此方法。This method is not used by this class.

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

此类未使用此方法。This method is not used by this class.

DecryptPassword(Byte[])

解密已加密的密码。Decrypts an encrypted password.

(继承自 MembershipProvider)
DeleteUser(String, Boolean)

此类未使用此方法。This method is not used by this class.

EncryptPassword(Byte[])

对密码进行加密。Encrypts a password.

(继承自 MembershipProvider)
EncryptPassword(Byte[], MembershipPasswordCompatibilityMode)

使用指定的密码兼容性模式对指定密码进行加密。Encrypts the specified password using the specified password-compatibility mode.

(继承自 MembershipProvider)
Equals(Object)

确定指定的对象是否等于当前对象。Determines whether the specified object is equal to the current object.

(继承自 Object)
FindUsersByEmail(String, Int32, Int32, Int32)

此类未使用此方法。This method is not used by this class.

FindUsersByName(String, Int32, Int32, Int32)

此类未使用此方法。This method is not used by this class.

GetAllUsers(Int32, Int32, Int32)

此类未使用此方法。This method is not used by this class.

GetHashCode()

用作默认哈希函数。Serves as the default hash function.

(继承自 Object)
GetNumberOfUsersOnline()

此类未使用此方法。This method is not used by this class.

GetPassword(String, String)

此类未使用此方法。This method is not used by this class.

GetType()

获取当前实例的 TypeGets the Type of the current instance.

(继承自 Object)
GetUser(Object, Boolean)

此类未使用此方法。This method is not used by this class.

GetUser(String, Boolean)

此类未使用此方法。This method is not used by this class.

GetUserNameByEmail(String)

此类未使用此方法。This method is not used by this class.

Initialize(String, NameValueCollection)

初始化配置生成器。Initializes the configuration builder.

(继承自 ProviderBase)
Logout()

注销用户。Logs out the user.

MemberwiseClone()

创建当前 Object 的浅表副本。Creates a shallow copy of the current Object.

(继承自 Object)
OnValidatingPassword(ValidatePasswordEventArgs)

如果定义了事件处理程序,则引发 ValidatingPassword 事件。Raises the ValidatingPassword event if an event handler has been defined.

(继承自 MembershipProvider)
ResetPassword(String, String)

此类未使用此方法。This method is not used by this class.

ToString()

返回一个表示当前对象的 string。Returns a string that represents the current object.

(继承自 Object)
UnlockUser(String)

此类未使用此方法。This method is not used by this class.

UpdateUser(MembershipUser)

此类未使用此方法。This method is not used by this class.

ValidateUser(String, String)

使用操作系统提供的标识自动对当前用户进行身份验证。Automatically authenticates the current user by using the identity supplied by the operating system.

事件

ValidatingPassword

在创建用户、更改密码或重置密码时发生。Occurs when a user is created, a password is changed, or a password is reset.

(继承自 MembershipProvider)

适用于

另请参阅