WindowsAuthenticationEventHandler 代理人
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
WindowsAuthenticationModule の WindowsAuthentication_OnAuthenticate イベントを処理するメソッドを表します。
public delegate void WindowsAuthenticationEventHandler(System::Object ^ sender, WindowsAuthenticationEventArgs ^ e);
public delegate void WindowsAuthenticationEventHandler(object sender, WindowsAuthenticationEventArgs e);
type WindowsAuthenticationEventHandler = delegate of obj * WindowsAuthenticationEventArgs -> unit
Public Delegate Sub WindowsAuthenticationEventHandler(sender As Object, e As WindowsAuthenticationEventArgs)
- sender
- Object
イベントのソース。
イベント データを格納している WindowsAuthenticationEventArgs。
次のコード例では、WindowsAuthentication_OnAuthenticate イベントを使用して、現在HttpContextの の プロパティをカスタム IPrincipal オブジェクトに設定Userします。
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
デリゲートは WindowsAuthenticationEventHandler 、 クラスの イベントに対して Authenticate 定義されます WindowsAuthenticationModule 。 クラスの イベントに Authenticate アクセスするには、ASP.NET アプリケーションの WindowsAuthenticationModule Global.asax ファイルで WindowsAuthentication_OnAuthenticate という名前のサブルーチンを指定します。 イベントは Authenticate 、イベント中に発生します AuthenticateRequest 。
は WindowsAuthenticationModule 、 WindowsAuthenticationEventArgs 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 モジュールである場合にのみ発生します。
Get |
指定したデリゲートによって表されるメソッドを表すオブジェクトを取得します。 |
製品 | バージョン |
---|---|
.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 |
.NET に関するフィードバック
.NET はオープンソース プロジェクトです。 フィードバックを提供するにはリンクを選択します。