WindowsAuthenticationEventArgs.Identity Tulajdonság

Definíció

Lekéri a Windows identitást a WindowsAuthenticationEventArgs konstruktornak.

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

Tulajdonság értéke

A WindowsAuthenticationEventArgs konstruktornak átadott Windows identitás.

Példák

Az alábbi példakód az WindowsAuthentication_OnAuthenticate esemény használatával állítja be az User aktuális HttpContext tulajdonságot egy egyéni IPrincipal objektumra.

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

Megjegyzések

A WindowsAuthenticationModule egy WindowsAuthenticationEventArgs objektumot hoz létre az IIS és az aktuális HttpContext által biztosított Windows identitás használatával, és átadja azt a WindowsAuthentication_OnAuthenticate eseménynek.

Ha az IIS névtelen hitelesítést használ, a Identity tulajdonság a metódus által GetAnonymous visszaadott identitásra van állítva.

A következőre érvényes:

Lásd még