WindowsAuthenticationEventArgs.User プロパティ

定義

現在の要求に関連付ける IPrincipal オブジェクトを取得または設定します。

public:
 property System::Security::Principal::IPrincipal ^ User { System::Security::Principal::IPrincipal ^ get(); void set(System::Security::Principal::IPrincipal ^ value); };
public System.Security.Principal.IPrincipal User { get; set; }
member this.User : System.Security.Principal.IPrincipal with get, set
Public Property User As IPrincipal

プロパティ値

現在の要求に関連付ける IPrincipal オブジェクト。

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

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

注釈

User プロパティを使用して、現在のUserHttpContext プロパティをカスタム IPrincipal オブジェクトに設定できます。

User イベント中に プロパティの値を指定しない場合、IIS によって提供される Windows ID が現在の要求の ID として使用されます。 IIS が匿名認証を使用する場合、 Identity プロパティは、 GetAnonymous メソッドによって返される ID に設定されます。

適用対象

こちらもご覧ください