AuthenticationService 类

定义

启用作为 Web 服务对 ASP.NET Forms 身份验证的访问。

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
继承
AuthenticationService
属性

注解

对象 AuthenticationService 使你能够通过 Windows Communication Foundation (WCF) 服务对用户进行身份验证。 当必须从存储用户凭据的 Web 应用程序外部的应用程序 ASP.NET 成员身份对用户进行身份验证时,可以使用 WCF 身份验证服务。 应用程序必须能够以 SOAP 格式发送和使用消息。 AuthenticationService通过 类,可以让用户登录、注销用户、验证凭据、检查身份验证状态、自定义身份验证以及设置身份验证 Cookie。

AuthenticationService 包含四个只能通过 WCF 服务访问的方法: IsLoggedInLoginLogoutValidateUser 方法。 若要调用这些方法,请在 Web 服务器上启用身份验证服务,然后将与 WCF 兼容的客户端应用程序连接到 Web 服务。 有关如何配置身份验证服务的信息,请参阅 如何:启用 WCF 身份验证服务

若要登录用户,请将用户凭据传递给 Login 方法。 如果凭据有效, AuthenticationService 类将创建身份验证 Cookie。 如果身份验证 Cookie 尚未过期,则表明用户凭据已经过身份验证,并且无需再次验证凭据。 (无 Cookie 身份验证不能通过 AuthenticationService class.)

可以 AuthenticationService 引发两个事件: AuthenticatingCreatingCookie。 验证 Authenticating 用户凭据时发生 该事件。 为 事件创建事件处理程序, Authenticating 以自定义验证用户凭据的方式。 在 CreatingCookie 验证用户凭据后设置身份验证 Cookie 时发生该事件。 为 事件创建事件处理程序以 CreatingCookie 自定义身份验证 Cookie。

方法 ValidateUser 检查用户凭据是否进行身份验证,但不返回身份验证票证。 ValidateUser当用户之前已登录并且你必须检查凭据在新应用程序会话开始时仍然有效时使用 。

有关从控制台应用程序使用 WCF 身份验证服务的示例,请参阅 演练:使用 ASP.NET 应用程序服务

构造函数

AuthenticationService()

初始化 AuthenticationService 类的新实例。

方法

Equals(Object)

确定指定对象是否等于当前对象。

(继承自 Object)
GetHashCode()

作为默认哈希函数。

(继承自 Object)
GetType()

获取当前实例的 Type

(继承自 Object)
IsLoggedIn()

确定当前用户是否已经过身份验证。

Login(String, String, String, Boolean)

检查用户凭据,如果凭据有效,则创建一个身份验证票证 (Cookie)。

Logout()

清除浏览器中的身份验证票证 (Cookie)。

MemberwiseClone()

创建当前 Object 的浅表副本。

(继承自 Object)
ToString()

返回表示当前对象的字符串。

(继承自 Object)
ValidateUser(String, String, String)

在不颁发身份验证票证的情况下对用户凭据进行身份验证。

事件

Authenticating

当验证用户凭据时发生。

CreatingCookie

当设置身份验证 Cookie 时发生。

适用于

另请参阅