AuthenticatingEventArgs.AuthenticationIsComplete 属性

定义

获取或设置一个值,该值指示用户凭据是否已经过身份验证。

public:
 property bool AuthenticationIsComplete { bool get(); void set(bool value); };
public bool AuthenticationIsComplete { get; set; }
member this.AuthenticationIsComplete : bool with get, set
Public Property AuthenticationIsComplete As Boolean

属性值

Boolean

如果执行了验证用户凭据的所有步骤,则为 true;否则为 false

示例

以下示例演示一个事件处理程序,该事件处理程序将传递 UserNamePassword 值传递给自定义成员身份提供程序以验证用户凭据。 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

注解

可以设置属性 AuthenticationIsComplete 以指示类是否 AuthenticationService 必须对用户凭据进行身份验证。 true如果是AuthenticationIsComplete,则AuthenticationService类不会通过默认成员身份提供程序验证用户凭据。 而是使用值来确定 Authenticated 是否创建身份验证 Cookie。

false如果是AuthenticationIsComplete,则AuthenticationService类通过默认成员身份提供程序验证用户凭据,并覆盖属性中的Authenticated值。

适用于

另请参阅