WindowsAuthenticationModule.Authenticate イベントとは何? わかりやすく解説 Weblio辞書 (original) (raw)

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

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

Visual Basic (宣言)

Public Event Authenticate As WindowsAuthenticationEventHandler

Visual Basic (使用法)

Dim instance As WindowsAuthenticationModule Dim handler As WindowsAuthenticationEventHandler

AddHandler instance.Authenticate, handler

C#

public event WindowsAuthenticationEventHandler Authenticate

C++

public: event WindowsAuthenticationEventHandler^ Authenticate { void add (WindowsAuthenticationEventHandler^ value); void remove (WindowsAuthenticationEventHandler^ value); }

J#

/** @event */ public void add_Authenticate (WindowsAuthenticationEventHandler value)

/** @event */ public void remove_Authenticate (WindowsAuthenticationEventHandler value)

JScript

JScript では、イベント使用できますが、新規に宣言することはできません。

解説解説

Authenticate イベントは、AuthenticateRequest イベント時に生成されます。

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

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

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

使用例使用例

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

Visual Basic

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

C#

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

プラットフォームプラットフォーム

Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

開発プラットフォーム中には.NET Framework によってサポートされていないバージョンありますサポートされているバージョンについては、「システム要件」を参照してください

バージョン情報バージョン情報

.NET Framework
サポート対象 : 2.01.11.0

参照参照

関連項目
WindowsAuthenticationModule クラス
WindowsAuthenticationModule メンバ
System.Web.Security 名前空間
その他の技術情報
Windows 認証プロバイダ
Global.asax 構文