Share via


WindowsAuthenticationEventArgs.Identity Proprietà

Definizione

Ottiene l'identità Windows passata al costruttore 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

Valore della proprietà

WindowsIdentity

Identità Windows passata al costruttore WindowsAuthenticationEventArgs.

Esempio

Nell'esempio di codice seguente viene usato l'evento WindowsAuthentication_OnAuthenticate per impostare la User proprietà dell'oggetto corrente HttpContext su un oggetto personalizzato 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

Commenti

Costruisce WindowsAuthenticationModule un WindowsAuthenticationEventArgs oggetto usando l'identità Windows fornita da IIS e l'oggetto corrente HttpContext e lo passa all'evento WindowsAuthentication_OnAuthenticate.

Se IIS usa l'autenticazione anonima, la Identity proprietà viene impostata sull'identità restituita dal GetAnonymous metodo .

Si applica a

Vedi anche