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 イベントを使用して、 User 現在 HttpContext の の プロパティをカスタム 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使用して、現在HttpContextの のプロパティをUserカスタム IPrincipal オブジェクトに設定できます。

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

適用対象

こちらもご覧ください