WindowsAuthenticationModule.Authenticate イベント

定義

アプリケーションが現在の要求を認証するときに発生します。

public:
 event System::Web::Security::WindowsAuthenticationEventHandler ^ Authenticate;
public event System.Web.Security.WindowsAuthenticationEventHandler Authenticate;
member this.Authenticate : System.Web.Security.WindowsAuthenticationEventHandler 
Public Custom Event Authenticate As WindowsAuthenticationEventHandler 

イベントの種類

次のコード例では、 WindowsAuthentication_OnAuthenticate イベントを使用して、 User 現在 HttpContext の の プロパティをカスタム IPrincipal オブジェクトに設定します。

public void WindowsAuthentication_OnAuthenticate(object sender, WindowsAuthenticationEventArgs args)
{
  if (!args.Identity.IsAnonymous)
  {
    args.User = new Samples.AspNet.Security.MyPrincipal(args.Identity);
  }
}
Public Sub WindowsAuthentication_OnAuthenticate(sender As Object, args As WindowsAuthenticationEventArgs)
  If Not args.Identity.IsAnonymous Then
    args.User = New Samples.AspNet.Security.MyPrincipal(args.Identity)
  End If
End Sub

注釈

イベントは Authenticate 、イベント中に発生します AuthenticateRequest

クラスのイベントに Authenticate アクセスするには、ASP.NET アプリケーションの WindowsAuthenticationModule Global.asax ファイルで WindowsAuthentication_OnAuthenticate という名前のサブルーチンを指定します。

WindowsAuthentication_OnAuthenticate イベントにUserWindowsAuthenticationEventArgs指定された オブジェクトの プロパティを使用して、現在HttpContextの プロパティをUserカスタム IPrincipal オブジェクトに設定できます。 WindowsAuthentication_OnAuthenticate イベント中に プロパティのUser値を指定しない場合、IIS によって提供される Windows ID が現在の要求の ID として使用されます。 IIS で匿名認証を使用する Identity 場合、 プロパティは メソッドによって GetAnonymous 返される ID に設定されます。

WindowsAuthentication_OnAuthenticate イベントは、認証Modeが にWindows設定されWindowsAuthenticationModule、 がアプリケーションのアクティブな HTTP モジュールである場合にのみ発生します。

Note

統合モードで実行されている IIS 7.0 では、AuthenticateASP.NET WindowsAuthenticationModule と IIS AnonymousAuthenticationModule モジュールのWindowsAuthenticationModule両方が有効になっている場合、 のイベントは発生しません。 このシナリオでは、認証通知を受信するには、 インスタンスのイベントをAuthenticateRequestHttpApplicationサブスクライブします。 統合モードでの互換性の問題の詳細については、「 ASP.NET アプリケーションを IIS 6.0 から IIS 7.0 に移動する」を参照してください。

適用対象

こちらもご覧ください