WindowsAuthenticationModule Klass

Definition

Anger användarens identitet för ett ASP.NET program när Windows authentication är aktiverat. Det går inte att ärva den här klassen.

public ref class WindowsAuthenticationModule sealed : System::Web::IHttpModule
public sealed class WindowsAuthenticationModule : System.Web.IHttpModule
type WindowsAuthenticationModule = class
    interface IHttpModule
Public NotInheritable Class WindowsAuthenticationModule
Implements IHttpModule
Arv
WindowsAuthenticationModule
Implementeringar

Exempel

I följande kodexempel används händelsen WindowsAuthentication_OnAuthenticate för att ange User egenskapen för den aktuella HttpContext till ett anpassat IPrincipal objekt.

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

Kommentarer

När autentiseringen Mode är inställd på Windows anger WindowsAuthenticationModule egenskapen User för den aktuella HttpContext till ett IPrincipal-objekt som representerar den Windows identitet som tillhandahålls av IIS för den aktuella begäran. Om IIS använder anonym autentisering WindowsAuthenticationModule använder den identitet som returneras av GetAnonymous metoden.

WindowsAuthenticationModule Exponerar en Authenticate händelse som gör att du kan ange ett anpassat IPrincipal objekt för egenskapen för User den aktuella HttpContext. Händelsen Authenticate nås genom att ange en underrutin med namnet WindowsAuthentication_OnAuthenticate i filen Global.asax för ditt ASP.NET-program.

Note

I IIS 7.0 stöds inte att använda WindowsAuthenticationModule klassen med FormsAuthenticationModule klassen. Mer information om kompatibilitetsproblem i integrerat läge finns i Moving an ASP.NET Application from IIS 6.0 to IIS 7.0.

Konstruktorer

Name Description
WindowsAuthenticationModule()

Skapar en instans av WindowsAuthenticationModule klassen.

Metoder

Name Description
Dispose()

Släpper alla resurser, förutom minne, som används av WindowsAuthenticationModule.

Equals(Object)

Avgör om det angivna objektet är lika med det aktuella objektet.

(Ärvd från Object)
GetHashCode()

Fungerar som standard-hash-funktion.

(Ärvd från Object)
GetType()

Hämtar den aktuella instansen Type .

(Ärvd från Object)
Init(HttpApplication)

Initierar WindowsAuthenticationModule-objektet.

MemberwiseClone()

Skapar en ytlig kopia av den aktuella Object.

(Ärvd från Object)
ToString()

Returnerar en sträng som representerar det aktuella objektet.

(Ärvd från Object)

Händelser

Name Description
Authenticate

Inträffar när programmet autentiserar den aktuella begäran.

Gäller för

Se även