Sdílet prostřednictvím


WindowsAuthenticationEventArgs.Identity Vlastnost

Definice

Získá Windows identitu předanou konstruktoruWindowsAuthenticationEventArgs.

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

Hodnota vlastnosti

WindowsIdentity

Identita Windows předána konstruktoruWindowsAuthenticationEventArgs.

Příklady

Následující příklad kódu používá WindowsAuthentication_OnAuthenticate událost k nastavení User vlastnosti aktuální HttpContext na vlastní 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

Poznámky

WindowsAuthenticationEventArgs Vytvoří WindowsAuthenticationModule objekt pomocí Windows identity poskytované službou IIS a aktuální HttpContext a předá ho události WindowsAuthentication_OnAuthenticate.

Pokud služba IIS používá anonymní ověřování, Identity vlastnost je nastavena na identitu vrácenou metodou GetAnonymous .

Platí pro

Viz také