英語で読む

次の方法で共有


WindowsAuthenticationEventHandler 代理人

定義

WindowsAuthenticationModuleWindowsAuthentication_OnAuthenticate イベントを処理するメソッドを表します。

C#
public delegate void WindowsAuthenticationEventHandler(object sender, WindowsAuthenticationEventArgs e);

パラメーター

sender
Object

イベントのソース。

e
WindowsAuthenticationEventArgs

イベント データを格納している WindowsAuthenticationEventArgs

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

C#
public void WindowsAuthentication_OnAuthenticate(object sender, WindowsAuthenticationEventArgs args)
{
  if (!args.Identity.IsAnonymous)
  {
    args.User = new Samples.AspNet.Security.MyPrincipal(args.Identity);
  }
}

注釈

デリゲートは WindowsAuthenticationEventHandler 、 クラスの イベントに対して Authenticate 定義されます WindowsAuthenticationModule 。 クラスの イベントに Authenticate アクセスするには、ASP.NET アプリケーションの WindowsAuthenticationModule Global.asax ファイルで WindowsAuthentication_OnAuthenticate という名前のサブルーチンを指定します。 イベントは Authenticate 、イベント中に発生します AuthenticateRequest

WindowsAuthenticationModuleWindowsAuthenticationEventArgs IIS によって提供される Windows ID と現在 HttpContext の を使用して オブジェクトを構築し、 それを WindowsAuthentication_OnAuthenticate イベントに渡します。

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

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

拡張メソッド

GetMethodInfo(Delegate)

指定したデリゲートによって表されるメソッドを表すオブジェクトを取得します。

適用対象

製品 バージョン
.NET Framework 1.1, 2.0, 3.0, 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

こちらもご覧ください