AuthenticationService.Login(String, String, String, Boolean) 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
檢查使用者憑證,若憑證有效,會建立認證單(Cookie)。
public:
bool Login(System::String ^ username, System::String ^ password, System::String ^ customCredential, bool isPersistent);
[System.ServiceModel.OperationContract]
public bool Login(string username, string password, string customCredential, bool isPersistent);
[<System.ServiceModel.OperationContract>]
member this.Login : string * string * string * bool -> bool
Public Function Login (username As String, password As String, customCredential As String, isPersistent As Boolean) As Boolean
參數
- username
- String
需要驗證的使用者名稱。
- password
- String
指定使用者的密碼。
- customCredential
- String
除了 和 username之外,還要驗證password的值(如果有的話)。
- isPersistent
- Boolean
一個表示認證工單是否在多個會話間仍然有效的值。
傳回
true若使用者憑證有效;否則,。 false
- 屬性
例外狀況
userName 或 password 為 null。
備註
此 Login 方法透過會員服務提供者驗證使用者憑證。 你可以使用預設的會員服務提供者,或在執行時指定自訂會員服務提供者。 該 AuthenticationService 類別通過 userName 和 password 到成員提供者的方法 ValidateUser ,但不通過 customCredential。 若 ValidateUser 返回 true, AuthenticationService 則會以 Cookie 形式產生認證工單。 將參數設定 isPersistent 為 true 建立一個持續超過當前會話的認證工單。
Note
請務必同時使用認證服務與安全套接字層(SSL,透過 HTTPS 進行)來保護敏感資料。
此 Login 方法提升事件與 Authenticating 事件本身 CreatingCookie 。 建立事件處理程序以 Authenticating 自訂認證,例如透過非預設成員提供者驗證憑證 customCredential 或檢查值。 這些 customCredential 值不會被預設會員提供者驗證。 若要自訂認證 Cookie,請建立事件處理程序。CreatingCookie
Note
不要從網頁伺服器上執行的程式碼呼叫該 Login 方法。 你只會在 WCF 服務中呼叫這個 Login 方法。 欲了解更多資訊,請參見 ASP.NET 認證。