ClientWindowsAuthenticationMembershipProvider.ValidateUser 方法

定义

使用操作系统提供的标识自动对当前用户进行身份验证。

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

参数

username
String

必须是 Emptynull

password
String

必须是 Emptynull

返回

始终 true

例外

username 不是 Emptynull

-或-

password 不是 Emptynull

示例

以下示例代码演示如何使用此方法通过 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 类时,staticMembership.ValidateUser 方法将此方法用于其实现。 ClientWindowsAuthenticationMembershipProvider.ValidateUser 方法会自动对当前用户进行身份验证,并将 staticThread.CurrentPrincipal 属性设置为包含当前 WindowsIdentityClientRolePrincipal 对象。 如果为应用程序配置了 ClientRoleProvider,则可以使用 ClientRolePrincipal 对象从角色服务中检索用户角色信息。

适用于

另请参阅