WindowsAuthenticationEventHandler Delegado

Definición

Representa el método que controla el evento WindowsAuthentication_OnAuthenticate de un WindowsAuthenticationModule.Represents the method that handles the WindowsAuthentication_OnAuthenticate event of a WindowsAuthenticationModule.

public delegate void WindowsAuthenticationEventHandler(System::Object ^ sender, WindowsAuthenticationEventArgs ^ e);
public delegate void WindowsAuthenticationEventHandler(object sender, WindowsAuthenticationEventArgs e);
type WindowsAuthenticationEventHandler = delegate of obj * WindowsAuthenticationEventArgs -> unit
Public Delegate Sub WindowsAuthenticationEventHandler(sender As Object, e As WindowsAuthenticationEventArgs)

Parámetros

sender
Object

Origen del evento.The source of the event.

e
WindowsAuthenticationEventArgs

Objeto WindowsAuthenticationEventArgs que contiene los datos del evento.A WindowsAuthenticationEventArgs that contains the event data.

Ejemplos

En el ejemplo de código siguiente se utiliza el evento WindowsAuthentication_OnAuthenticate para establecer la User propiedad del HttpContext objeto actual en un IPrincipal objeto personalizado.The following code example uses the WindowsAuthentication_OnAuthenticate event to set the User property of the current HttpContext to a custom IPrincipal object.

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

Comentarios

El WindowsAuthenticationEventHandler delegado se define para el Authenticate evento de la WindowsAuthenticationModule clase.The WindowsAuthenticationEventHandler delegate is defined for the Authenticate event of the WindowsAuthenticationModule class. Puede tener acceso al Authenticate evento de la WindowsAuthenticationModule clase especificando una subrutina denominada WindowsAuthentication_OnAuthenticate en el archivo global. asax de la aplicación ASP.net.You can access the Authenticate event of the WindowsAuthenticationModule class by specifying a subroutine named WindowsAuthentication_OnAuthenticate in the Global.asax file for your ASP.NET application. El Authenticate evento se genera durante el AuthenticateRequest evento.The Authenticate event is raised during the AuthenticateRequest event.

WindowsAuthenticationModuleConstruye un WindowsAuthenticationEventArgs objeto utilizando la identidad de Windows proporcionada por IIS y el actual HttpContext y lo pasa al evento WindowsAuthentication_OnAuthenticate .The WindowsAuthenticationModule constructs a WindowsAuthenticationEventArgs object using the Windows identity supplied by IIS and the current HttpContext and passes it to the WindowsAuthentication_OnAuthenticate event.

Puede utilizar la User propiedad del WindowsAuthenticationEventArgs objeto proporcionado al evento WindowsAuthentication_OnAuthenticate para establecer la User propiedad del HttpContext objeto actual en un IPrincipal objeto personalizado.You can use the User property of the WindowsAuthenticationEventArgs object supplied to the WindowsAuthentication_OnAuthenticate event to set the User property of the current HttpContext to a custom IPrincipal object. Si no especifica un valor para la User propiedad durante el evento WindowsAuthentication_OnAuthenticate , la identidad de Windows proporcionada por IIS se utiliza como la identidad de la solicitud actual.If you do not specify a value for the User property during the WindowsAuthentication_OnAuthenticate event, the Windows identity supplied by IIS is used as the identity for the current request. Si IIS utiliza la autenticación anónima, la Identity propiedad del WindowsAuthenticationEventArgs objeto se establece en la identidad devuelta por el GetAnonymous método.If IIS uses anonymous authentication, then the Identity property of the WindowsAuthenticationEventArgs object is set to the identity returned by the GetAnonymous method.

El evento WindowsAuthentication_OnAuthenticate solo se genera cuando la autenticación Mode se establece en Windows y WindowsAuthenticationModule es un módulo http activo para la aplicación.The WindowsAuthentication_OnAuthenticate event is only raised when the authentication Mode is set to Windows and the WindowsAuthenticationModule is an active HTTP module for the application.

Métodos de extensión

GetMethodInfo(Delegate)

Obtiene un objeto que representa el método representado por el delegado especificado.Gets an object that represents the method represented by the specified delegate.

Se aplica a