AuthenticatingEventArgs.Password Property
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Gets the password for the user.
public:
property System::String ^ Password { System::String ^ get(); };
public string Password { get; }
member this.Password : string
Public ReadOnly Property Password As String
The password to validate.
The following example shows an event handler that passes UserName and Password values to a custom membership provider to validate the user credentials. The event handler sets Authenticated to the return value of the ValidateUser method and sets AuthenticationIsComplete to true
so that the AuthenticationService class does not validate the credentials.
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
You use the Password property to retrieve the password during the Authenticating event.
Toode | Versioonid |
---|---|
.NET Framework | 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
Toote „.NET“ tagasiside
.NET on avatud lähtekoodiga projekt. Tagasiside andmiseks valige link: