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返回值,并将 设置为 trueAuthenticationIsComplete ,以便AuthenticationService类不验证凭据。

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 检索密码。

适用于

另请参阅