WindowsAuthenticationEventArgs.Identity Propriété

Définition

Obtient l'identité Windows passée au constructeur 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

Valeur de propriété

WindowsIdentity

Identité Windows passée au constructeur WindowsAuthenticationEventArgs.

Exemples

L’exemple de code suivant utilise l’événement WindowsAuthentication_OnAuthenticate pour définir la User propriété du courant HttpContext sur un objet personnalisé 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

Remarques

Construit WindowsAuthenticationModule un WindowsAuthenticationEventArgs objet à l’aide de l’identité Windows fournie par IIS et du courant HttpContext et le transmet à l’événement WindowsAuthentication_OnAuthenticate.

Si IIS utilise l’authentification anonyme, la Identity propriété est définie sur l’identité retournée par la GetAnonymous méthode.

S’applique à

Voir aussi