WindowsAuthenticationEventHandler Delegat

Definicja

Reprezentuje metodę, która obsługuje zdarzenie WindowsAuthentication_OnAuthenticate obiektu 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)

Parametry

sender
Object

Źródło zdarzenia.

e
WindowsAuthenticationEventArgs

Element WindowsAuthenticationEventArgs zawierający dane zdarzenia.

Przykłady

Poniższy przykład kodu używa zdarzenia WindowsAuthentication_OnAuthenticate , aby ustawić User właściwość bieżącego HttpContext obiektu na obiekt niestandardowy 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

Uwagi

Delegat WindowsAuthenticationEventHandler jest definiowany Authenticate dla zdarzenia WindowsAuthenticationModule klasy. Możesz uzyskać dostęp do Authenticate zdarzenia WindowsAuthenticationModule klasy, określając podprotynę o nazwie WindowsAuthentication_OnAuthenticate w pliku Global.asax dla aplikacji ASP.NET. Zdarzenie Authenticate jest zgłaszane podczas AuthenticateRequest zdarzenia.

Obiekt WindowsAuthenticationModule tworzy WindowsAuthenticationEventArgs obiekt przy użyciu tożsamości systemu Windows dostarczonej przez usługi IIS i bieżące HttpContext i przekazuje go do zdarzenia WindowsAuthentication_OnAuthenticate .

Można użyć User właściwości obiektu dostarczonego WindowsAuthenticationEventArgs do zdarzenia WindowsAuthentication_OnAuthenticate , aby ustawić User właściwość bieżącego HttpContext obiektu na obiekt niestandardowy IPrincipal . Jeśli nie określisz wartości właściwości User podczas zdarzenia WindowsAuthentication_OnAuthenticate , tożsamość systemu Windows dostarczona przez usługi IIS jest używana jako tożsamość dla bieżącego żądania. Jeśli usługi IIS używają uwierzytelniania anonimowegoWindowsAuthenticationEventArgs, Identity właściwość obiektu jest ustawiona na tożsamość zwróconą przez metodęGetAnonymous.

Zdarzenie WindowsAuthentication_OnAuthenticate jest zgłaszane tylko wtedy, gdy uwierzytelnianie Mode jest ustawione Windows i WindowsAuthenticationModule jest aktywnym modułem HTTP dla aplikacji.

Metody rozszerzania

GetMethodInfo(Delegate)

Pobiera obiekt reprezentujący metodę reprezentowaną przez określonego delegata.

Dotyczy

Zobacz też