共用方式為


AuthenticatingEventArgs.Password 屬性

定義

取得使用者的密碼。

public:
 property System::String ^ Password { System::String ^ get(); };
public string Password { get; }
member this.Password : string
Public ReadOnly Property Password As String

屬性值

要驗證的密碼。

範例

下列範例顯示事件處理程式,會將 和 Password 值傳遞UserName至自定義成員資格提供者,以驗證用戶認證。 事件處理程式會將 設定 Authenticated 為 方法的傳回值, ValidateUser 並將 設定 AuthenticationIsCompletetrueAuthenticationService 讓 類別不會驗證認證。

void AuthenticationService_Authenticating(object sender, System.Web.ApplicationServices.AuthenticatingEventArgs e)
{
    if (e.UserName.IndexOf("@contoso.com") >= 0)
    {
        e.Authenticated = Membership.Providers["ContosoSqlProvider"].ValidateUser(e.UserName, e.Password);
    }
    else if (e.UserName.IndexOf("@fabrikam.com") >= 0)
    {
        e.Authenticated = Membership.Providers["FabrikamSqlProvider"].ValidateUser(e.UserName, e.Password);
    }
    else
    {
        e.Authenticated = Membership.Provider.ValidateUser(e.UserName, e.Password);
    }
    e.AuthenticationIsComplete = true;
}
Sub AuthenticationService_Authenticating _
   (ByVal sender As Object, _
    ByVal e As System.Web.ApplicationServices.AuthenticatingEventArgs)
    
    If (e.Username.IndexOf("@contoso.com") >= 0) Then
        e.Authenticated = Membership.Providers("ContosoSqlProvider").ValidateUser(e.Username, e.Password)
    ElseIf (e.Username.IndexOf("@fabrikam.com") >= 0) Then
        e.Authenticated = Membership.Providers("FabrikamSqlProvider").ValidateUser(e.Username, e.Password)
    Else
        e.Authenticated = Membership.Provider.ValidateUser(e.Username, e.Password)
    End If
    e.AuthenticationIsComplete = True
End Sub

備註

Password您可以使用 屬性來擷取事件期間Authenticating的密碼。

適用於

另請參閱