语言

AuthenticationService.ValidateUser(String, String, String) 方法

定义

在不颁发身份验证票证的情况下对用户凭据进行身份验证。

public:
 bool ValidateUser(System::String ^ username, System::String ^ password, System::String ^ customCredential);
[System.ServiceModel.OperationContract]
public bool ValidateUser(string username, string password, string customCredential);
[<System.ServiceModel.OperationContract>]
member this.ValidateUser : string * string * string -> bool
Public Function ValidateUser (username As String, password As String, customCredential As String) As Boolean

参数

username
String

要验证的用户名。

password
String

指定用户的密码。

customCredential
String

除和username(如果有)之外password要验证的值或值。

返回

true 如果用户凭据有效,则为否则,为 false.

属性

例外

userName 或 password 为 null.

注解

该方法 ValidateUser 对用户凭据进行身份验证,但不设置身份验证 Cookie。 如果没有身份验证 Cookie,即使凭据有效,用户也不会登录。

ValidateUser当必须检查用户的凭据是否有效而不收到身份验证 Cookie 时,请使用此方法。 例如,如果身份验证 Cookie 已存储在客户端应用程序中,但想要验证新会话启动时用户的凭据是否仍然有效,则可以执行此操作。

该方法 ValidateUser 将引发 Authenticating 事件,但不引发该 CreatingCookie 事件。

注释

不要从在 Web 服务器上执行的代码中调用 ValidateUser 该方法。 仅作为 WCF 服务的一部分调用 ValidateUser 该方法。 有关详细信息,请参阅 ASP.NET Authentication。

适用于

另请参阅