WindowsAuthenticationEventHandler デリゲートとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > WindowsAuthenticationEventHandler デリゲートの意味・解説 

WindowsAuthenticationEventHandler デリゲート

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

名前空間: System.Web.Security
アセンブリ: System.Web (system.web.dll 内)
構文構文

Public Delegate Sub WindowsAuthenticationEventHandler
 ( _
    sender As Object, _
    e As WindowsAuthenticationEventArgs _
)
Dim instance As New WindowsAuthenticationEventHandler(AddressOf
 HandlerMethod)
public delegate void WindowsAuthenticationEventHandler
 (
    Object sender,
    WindowsAuthenticationEventArgs e
)
public delegate void WindowsAuthenticationEventHandler
 (
    Object^ sender, 
    WindowsAuthenticationEventArgs^ e
)
/** @delegate */
public delegate void WindowsAuthenticationEventHandler
 (
    Object sender, 
    WindowsAuthenticationEventArgs e
)
JScript では、デリゲートは使用できますが、新規に宣言することはできません。

パラメータ

sender

イベントのソース。

e

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

解説解説

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

WindowsAuthenticationModule は、IIS によって提供された Windows ID と現在の HttpContext を使用して WindowsAuthenticationEventArgs オブジェクトを生成し、それを WindowsAuthentication_OnAuthenticate イベントに渡します。

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

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

使用例使用例

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

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
public void WindowsAuthentication_OnAuthenticate(object
 sender, WindowsAuthenticationEventArgs args)
{
  if (!args.Identity.IsAnonymous)
  {
    args.User = new Samples.AspNet.Security.MyPrincipal(args.Identity);
  }
}
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照



英和和英テキスト翻訳

英語⇒日本語日本語⇒英語

辞書ショートカット

すべての辞書の索引

WindowsAuthenticationEventHandler デリゲートのお隣キーワード

   

英語⇒日本語
日本語⇒英語
   



WindowsAuthenticationEventHandler デリゲートのページの著作権

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2026 Microsoft.All rights reserved.

©2026 GRAS Group, Inc.RSS