WindowsAuthenticationEventArgs.Identity Właściwość

Definicja

Pobiera tożsamość Windows przekazaną do konstruktoraWindowsAuthenticationEventArgs.

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

Wartość właściwości

WindowsIdentity

Tożsamość Windows przekazana do konstruktoraWindowsAuthenticationEventArgs.

Przykłady

W poniższym przykładzie kodu użyto zdarzenia WindowsAuthentication_OnAuthenticate , aby ustawić User właściwość bieżącego HttpContext obiektu na obiekt niestandardowy 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

Uwagi

Obiekt WindowsAuthenticationModule tworzy WindowsAuthenticationEventArgs obiekt przy użyciu tożsamości Windows dostarczonej przez usługi IIS oraz bieżącej HttpContext i przekazuje go do zdarzenia WindowsAuthentication_OnAuthenticate.

Jeśli usługi IIS używają uwierzytelniania anonimowego, Identity właściwość jest ustawiona na tożsamość zwróconą przez metodę GetAnonymous .

Dotyczy

Zobacz też