WindowsAuthenticationEventArgs.Identity プロパティ

定義

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

プロパティ値

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 設定されます。

適用対象

こちらもご覧ください