語言

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,即使憑證有效,使用者也無法登入。

當你必須在沒有收到認證 cookie 的情況下檢查使用者的憑證是否有效時,請使用此 ValidateUser 方法。 例如,如果驗證 Cookie 已經儲存在用戶端應用程式中,但你想確認新會話開始時使用者的憑證仍然有效,你可能會這麼做。

此ValidateUser方法提升事件,Authenticating但不提升事件。CreatingCookie

Note

不要從網頁伺服器上執行的程式碼呼叫該 ValidateUser 方法。 你只會在 WCF 服務中呼叫這個 ValidateUser 方法。 欲了解更多資訊,請參見 ASP.NET 認證。

適用於

另請參閱