WindowsAuthenticationEventArgs.Identity プロパティ
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
WindowsAuthenticationEventArgs コンストラクターに渡される Windows ID を取得します。
public:
property System::Security::Principal::WindowsIdentity ^ Identity { System::Security::Principal::WindowsIdentity ^ get(); };
public System.Security.Principal.WindowsIdentity Identity { get; }
member this.Identity : System.Security.Principal.WindowsIdentity
Public ReadOnly Property Identity As WindowsIdentity
プロパティ値
WindowsAuthenticationEventArgs コンストラクターに渡された Windows ID。
例
次のコード例では 、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
注釈
IIS WindowsAuthenticationModule によって提供されるWindows ID と現在HttpContextの ID を使用してオブジェクトを構築WindowsAuthenticationEventArgsし、WindowsAuthentication_OnAuthenticate イベントに渡します。
IIS が匿名認証を使用する Identity 場合、プロパティはメソッドによって返される ID に GetAnonymous 設定されます。