AuthenticatingEventArgs 类  
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
为 Authenticating 事件提供数据。
public ref class AuthenticatingEventArgs : EventArgspublic class AuthenticatingEventArgs : EventArgstype AuthenticatingEventArgs = class
    inherit EventArgsPublic Class AuthenticatingEventArgs
Inherits EventArgs- 继承
示例
以下示例演示一个事件处理程序, UserName 该事件处理程序将 和 Password 值传递给自定义成员资格提供程序以验证用户凭据。 事件处理程序将 设置为 Authenticated 方法的 ValidateUser 返回值,并将 设置为 AuthenticationIsCompletetrue , 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
注解
如果要自定义在运行时对用户凭据进行身份验证的方式,请为 Authenticating 事件创建处理程序。 类 AuthenticatingEventArgs 向任何 Authenticating 事件处理程序提供值。 通过使用此类中提供的属性,可以检索用户凭据以自定义身份验证。
类 AuthenticationService 在 Authenticating 验证用户凭据之前引发 事件。 类 AuthenticationService 构造 对象的实例, AuthenticatingEventArgs 并将其传递给任何 Authenticating 事件处理程序。
可以使用 UserName和 PasswordCustomCredential 属性检索用户凭据。 属性 CustomCredential 可以包含身份验证所需的其他值,例如标识号。
属性 Authenticated 指示用户凭据是否有效。 将 属性设置为 Authenticated 自定义身份验证的结果。 此外,如果已检查用户凭据,并且不希望AuthenticationService类通过默认成员身份提供程序检查用户凭据,则可以将 属性true设置为 AuthenticationIsComplete 。
属性
| Authenticated | 获取或设置一个值,该值指示用户凭据是否有效。 | 
| AuthenticationIsComplete | 获取或设置一个值,该值指示用户凭据是否已经过身份验证。 | 
| CustomCredential | 获取用于身份验证的其他用户值。 | 
| Password | 获取用户的密码。 | 
| UserName | 为用户获取身份验证名称。 | 
方法
| Equals(Object) | 确定指定对象是否等于当前对象。(继承自 Object) | 
| GetHashCode() | 作为默认哈希函数。(继承自 Object) | 
| GetType() | 获取当前实例的 Type。(继承自 Object) | 
| MemberwiseClone() | 创建当前 Object 的浅表副本。(继承自 Object) | 
| ToString() | 返回表示当前对象的字符串。(继承自 Object) |