AuthenticatingEventArgs クラス

定義

Authenticating イベントのデータを提供します。

public ref class AuthenticatingEventArgs : EventArgs
public class AuthenticatingEventArgs : EventArgs
type AuthenticatingEventArgs = class
    inherit EventArgs
Public Class AuthenticatingEventArgs
Inherits EventArgs
継承
AuthenticatingEventArgs

次の例は、 と Password の値をカスタム メンバーシップ プロバイダーに渡UserNameしてユーザーの資格情報を検証するイベント ハンドラーを示しています。 イベント ハンドラーは、 メソッドの戻り値にValidateUser設定Authenticatedし、 を に設定AuthenticationIsCompleteしてtrueAuthenticationServiceクラスが資格情報を検証しないようにします。

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 のイベント ハンドラーに渡します。

、および CustomCredential プロパティをUserNamePassword使用して、ユーザーの資格情報を取得できます。 プロパティには CustomCredential 、認証に必要な追加の値 (識別番号など) を含めることができます。

プロパティは Authenticated 、ユーザー資格情報が有効かどうかを示します。 プロパティは、 Authenticated カスタマイズした認証の結果に設定します。 さらに、ユーザー資格情報を確認し、クラスでAuthenticationIsComplete既定のメンバーシップ プロバイダーを介してユーザー資格情報をチェックさせたくないAuthenticationService場合は、 プロパティtrueを に設定します。

プロパティ

Authenticated

ユーザーの資格情報が有効かどうかを示す値を取得または設定します。

AuthenticationIsComplete

ユーザーの資格情報が認証されているかどうかを示す値を取得または設定します。

CustomCredential

ユーザーの認証に使用される追加の値を取得します。

Password

ユーザーのパスワードを取得します。

UserName

ユーザーの認証名を取得します。

メソッド

Equals(Object)

指定されたオブジェクトが現在のオブジェクトと等しいかどうかを判断します。

(継承元 Object)
GetHashCode()

既定のハッシュ関数として機能します。

(継承元 Object)
GetType()

現在のインスタンスの Type を取得します。

(継承元 Object)
MemberwiseClone()

現在の Object の簡易コピーを作成します。

(継承元 Object)
ToString()

現在のオブジェクトを表す文字列を返します。

(継承元 Object)

適用対象

こちらもご覧ください