WindowsAuthenticationEventArgs.Identity Egenskap

Definition

Hämtar den Windows identiteten som skickas till konstruktorn WindowsAuthenticationEventArgs.

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

Egenskapsvärde

Den Windows identitet som skickas till konstruktorn WindowsAuthenticationEventArgs.

Exempel

I följande kodexempel används händelsen WindowsAuthentication_OnAuthenticate för att ange User egenskapen för den aktuella HttpContext till ett anpassat IPrincipal objekt.

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

Kommentarer

WindowsAuthenticationModule konstruerar ett WindowsAuthenticationEventArgs-objekt med hjälp av den Windows identitet som tillhandahålls av IIS och den aktuella HttpContext och skickar det till händelsen WindowsAuthentication_OnAuthenticate.

Om IIS använder anonym autentisering Identity anges egenskapen till den identitet som returneras av GetAnonymous metoden.

Gäller för

Se även