AuthenticationService Klass

Definition

Ger åtkomst till ASP.NET formulärautentisering som en webbtjänst.

public ref class AuthenticationService
[System.ServiceModel.Activation.AspNetCompatibilityRequirements(RequirementsMode=System.ServiceModel.Activation.AspNetCompatibilityRequirementsMode.Required)]
[System.ServiceModel.ServiceBehavior(ConcurrencyMode=System.ServiceModel.ConcurrencyMode.Multiple, InstanceContextMode=System.ServiceModel.InstanceContextMode.Single, Namespace="http://asp.net/ApplicationServices/v200")]
[System.ServiceModel.ServiceContract(Namespace="http://asp.net/ApplicationServices/v200")]
public class AuthenticationService
[<System.ServiceModel.Activation.AspNetCompatibilityRequirements(RequirementsMode=System.ServiceModel.Activation.AspNetCompatibilityRequirementsMode.Required)>]
[<System.ServiceModel.ServiceBehavior(ConcurrencyMode=System.ServiceModel.ConcurrencyMode.Multiple, InstanceContextMode=System.ServiceModel.InstanceContextMode.Single, Namespace="http://asp.net/ApplicationServices/v200")>]
[<System.ServiceModel.ServiceContract(Namespace="http://asp.net/ApplicationServices/v200")>]
type AuthenticationService = class
Public Class AuthenticationService
Arv
AuthenticationService
Attribut

Kommentarer

Med objektet AuthenticationService kan du autentisera användare via en Windows Communication Foundation-tjänst (WCF). Du använder WCF-autentiseringstjänsten när du måste autentisera användare via ASP.NET medlemskap från ett program som ligger utanför webbprogrammet som lagrar användarautentiseringsuppgifterna. Programmet måste kunna skicka och använda meddelanden i SOAP-format. AuthenticationService Via klassen kan du logga in användare, logga ut användare, verifiera autentiseringsuppgifter, kontrollera autentiseringsstatus, anpassa autentisering och ange autentiseringscookie.

Klassen AuthenticationService innehåller fyra metoder som du endast ska komma åt via en WCF-tjänst: IsLoggedInmetoderna , Login, Logoutoch ValidateUser . Om du vill anropa dessa metoder aktiverar du autentiseringstjänsten på en webbserver och ansluter sedan ett WCF-kompatibelt klientprogram till webbtjänsten. Information om hur du konfigurerar autentiseringstjänsten finns i Så här aktiverar du WCF-autentiseringstjänsten.

Om du vill logga in användare skickar du autentiseringsuppgifterna Login till metoden . Om autentiseringsuppgifterna är giltiga AuthenticationService skapar klassen en autentiseringscookie. Om autentiseringscookien inte har upphört att gälla vet du att användarens autentiseringsuppgifter har autentiserats och att du inte behöver verifiera autentiseringsuppgifterna igen. (Cookiefri autentisering är inte tillgänglig via AuthenticationService klassen.)

AuthenticationService Kan generera två händelser: Authenticating och CreatingCookie. Händelsen Authenticating inträffar när användarautentiseringsuppgifterna verifieras. Skapa en händelsehanterare för händelsen för Authenticating att anpassa hur användarautentiseringsuppgifter verifieras. Händelsen CreatingCookie inträffar när autentiseringscookien anges när användarautentiseringsuppgifterna har verifierats. Skapa en händelsehanterare för händelsen för CreatingCookie att anpassa autentiseringscookien.

Metoden ValidateUser kontrollerar användarens autentiseringsuppgifter för autentisering, men returnerar inte ett autentiseringsärende. Använd ValidateUser när en användare tidigare har loggat in och du måste kontrollera att autentiseringsuppgifterna fortfarande är giltiga i början av en ny programsession.

Ett exempel på hur du använder WCF-autentiseringstjänsten från ett konsolprogram finns i Walkthrough: Using ASP.NET Application Services.

Konstruktorer

Name Description
AuthenticationService()

Initierar en ny instans av AuthenticationService klassen.

Metoder

Name Description
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)
IsLoggedIn()

Avgör om den aktuella användaren autentiseras.

Login(String, String, String, Boolean)

Kontrollerar autentiseringsuppgifterna och skapar en autentiseringsbiljett (cookie) om autentiseringsuppgifterna är giltiga.

Logout()

Rensar autentiseringsbiljetten (cookie) i webbläsaren.

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)
ValidateUser(String, String, String)

Autentiserar användarautentiseringsuppgifter utan att utfärda ett autentiseringsärende.

Händelser

Name Description
Authenticating

Inträffar när användarautentiseringsuppgifter verifieras.

CreatingCookie

Inträffar när autentiseringscookien anges.

Gäller för

Se även