MembershipProvider 类

定义

定义 ASP.NET 为使用自定义成员资格提供程序提供成员资格服务而实现的协定。Defines the contract that ASP.NET implements to provide membership services using custom membership providers.

public ref class MembershipProvider abstract : System::Configuration::Provider::ProviderBase
public abstract class MembershipProvider : System.Configuration.Provider.ProviderBase
type MembershipProvider = class
    inherit ProviderBase
Public MustInherit Class MembershipProvider
Inherits ProviderBase
继承
MembershipProvider
派生

注解

ASP.NET 成员资格旨在使你能够轻松地为 ASP.NET 应用程序使用多个不同的成员资格提供程序。ASP.NET membership is designed to enable you to easily use a number of different membership providers for your ASP.NET applications. 您可以使用 .NET Framework 附带的提供的成员资格提供程序,也可以实现您自己的提供程序。You can use the supplied membership providers that are included with the .NET Framework, or you can implement your own provider.

备注

如果你不熟悉 ASP.NET 的成员资格功能,请参阅 "成员资格简介",然后继续。If you are not familiar with the membership features of ASP.NET, see Introduction to Membership before continuing. 有关与成员资格相关的其他主题的列表,请参阅使用成员身份管理用户For a list of other topics related to membership, see Managing Users by Using Membership.

实现自定义成员资格提供程序时,需要继承MembershipProvider抽象类。When implementing a custom membership provider, you are required to inherit the MembershipProvider abstract class.

创建自定义成员资格提供程序有两个主要原因。There are two primary reasons for creating a custom membership provider.

  • 需要将成员身份信息存储在 .NET Framework 附带的成员资格提供程序不支持的数据源中,如 FoxPro 数据库、Oracle 数据库或其他数据源。You need to store membership information in a data source that is not supported by the membership providers included with the .NET Framework, such as a FoxPro database, an Oracle database, or other data source.

  • 需要使用与 .NET Framework 附带的提供程序所使用的数据库架构不同的数据库架构来管理成员身份信息。You need to manage membership information using a database schema that is different from the database schema used by the providers that ship with the .NET Framework. 这种情况的一个常见示例是公司或网站的 SQL Server 数据库中已存在的成员身份数据。A common example of this would be membership data that already exists in a SQL Server database for a company or Web site.

抽象类继承ProviderBase自抽象类。 MembershipProviderThe MembershipProvider abstract class inherits from the ProviderBase abstract class. MembershipProvider实现还必须实现的必需成员ProviderBaseMembershipProvider implementations must also implement the required members of ProviderBase.

构造函数

MembershipProvider()

初始化 MembershipProvider 类的新实例。Initializes a new instance of the MembershipProvider class.

属性

ApplicationName

使用自定义成员资格提供程序的应用程序的名称。The name of the application using the custom membership provider.

Description

获取一条简短的易懂描述,它适合在管理工具或其他用户界面 (UI) 中显示。Gets a brief, friendly description suitable for display in administrative tools or other user interfaces (UIs).

(继承自 ProviderBase)
EnablePasswordReset

指示成员资格提供程序是否配置为允许用户重置其密码。Indicates whether the membership provider is configured to allow users to reset their passwords.

EnablePasswordRetrieval

指示成员资格提供程序是否配置为允许用户检索其密码。Indicates whether the membership provider is configured to allow users to retrieve their passwords.

MaxInvalidPasswordAttempts

获取锁定成员资格用户前允许的无效密码或无效密码提示问题答案尝试次数。Gets the number of invalid password or password-answer attempts allowed before the membership user is locked out.

MinRequiredNonAlphanumericCharacters

获取有效密码中必须包含的最少特殊字符数。Gets the minimum number of special characters that must be present in a valid password.

MinRequiredPasswordLength

获取密码所要求的最小长度。Gets the minimum length required for a password.

Name

获得一个友好名称,用于在配置过程中引用提供程序。Gets the friendly name used to refer to the provider during configuration.

(继承自 ProviderBase)
PasswordAttemptWindow

获取在锁定成员资格用户之前允许的最大无效密码或无效密码提示问题答案尝试次数的分钟数。Gets the number of minutes in which a maximum number of invalid password or password-answer attempts are allowed before the membership user is locked out.

PasswordFormat

获取一个值,该值指示成员资格数据存储中存储密码的格式。Gets a value indicating the format for storing passwords in the membership data store.

PasswordStrengthRegularExpression

获取用于计算密码的正则表达式。Gets the regular expression used to evaluate a password.

RequiresQuestionAndAnswer

获取一个值,该值指示成员资格提供程序是否配置为要求用户在进行密码重置和检索时回答密码提示问题。Gets a value indicating whether the membership provider is configured to require the user to answer a password question for password reset and retrieval.

RequiresUniqueEmail

获取一个值,指示成员资格提供程序是否配置为要求每个用户名具有唯一的电子邮件地址。Gets a value indicating whether the membership provider is configured to require a unique email address for each user name.

方法

ChangePassword(String, String, String)

处理更新成员资格用户密码的请求。Processes a request to update the password for a membership user.

ChangePasswordQuestionAndAnswer(String, String, String, String)

处理更新成员资格用户的密码提示问题和答案的请求。Processes a request to update the password question and answer for a membership user.

CreateUser(String, String, String, String, String, Boolean, Object, MembershipCreateStatus)

将新的成员资格用户添加到数据源。Adds a new membership user to the data source.

DecryptPassword(Byte[])

解密已加密的密码。Decrypts an encrypted password.

DeleteUser(String, Boolean)

从成员资格数据源删除一个用户。Removes a user from the membership data source.

EncryptPassword(Byte[])

对密码进行加密。Encrypts a password.

EncryptPassword(Byte[], MembershipPasswordCompatibilityMode)

使用指定的密码兼容性模式对指定密码进行加密。Encrypts the specified password using the specified password-compatibility mode.

Equals(Object)

确定指定的对象是否等于当前对象。Determines whether the specified object is equal to the current object.

(继承自 Object)
FindUsersByEmail(String, Int32, Int32, Int32)

获取成员资格用户集合,这些用户的电子邮件地址包含要匹配的指定电子邮件地址。Gets a collection of membership users where the email address contains the specified email address to match.

FindUsersByName(String, Int32, Int32, Int32)

获取一个成员资格用户的集合,其中的用户名包含要匹配的指定用户名。Gets a collection of membership users where the user name contains the specified user name to match.

GetAllUsers(Int32, Int32, Int32)

获取数据源中的所有用户的集合,并显示在数据页中。Gets a collection of all the users in the data source in pages of data.

GetHashCode()

作为默认哈希函数。Serves as the default hash function.

(继承自 Object)
GetNumberOfUsersOnline()

获取当前访问该应用程序的用户数。Gets the number of users currently accessing the application.

GetPassword(String, String)

从数据源获取指定用户名所对应的密码。Gets the password for the specified user name from the data source.

GetType()

获取当前实例的 TypeGets the Type of the current instance.

(继承自 Object)
GetUser(Object, Boolean)

根据成员资格用户的唯一标识符从数据源获取用户信息。Gets user information from the data source based on the unique identifier for the membership user. 提供一个更新用户最近一次活动的日期/时间戳的选项。Provides an option to update the last-activity date/time stamp for the user.

GetUser(String, Boolean)

从数据源获取用户的信息。Gets information from the data source for a user. 提供一个更新用户最近一次活动的日期/时间戳的选项。Provides an option to update the last-activity date/time stamp for the user.

GetUserNameByEmail(String)

获取与指定电子邮件地址关联的用户名。Gets the user name associated with the specified email address.

Initialize(String, NameValueCollection)

初始化配置生成器。Initializes the configuration builder.

(继承自 ProviderBase)
MemberwiseClone()

创建当前 Object 的浅表副本。Creates a shallow copy of the current Object.

(继承自 Object)
OnValidatingPassword(ValidatePasswordEventArgs)

如果定义了事件处理程序,则引发 ValidatingPassword 事件。Raises the ValidatingPassword event if an event handler has been defined.

ResetPassword(String, String)

将用户密码重置为一个自动生成的新密码。Resets a user's password to a new, automatically generated password.

ToString()

返回表示当前对象的字符串。Returns a string that represents the current object.

(继承自 Object)
UnlockUser(String)

清除锁定,以便可以验证该成员资格用户。Clears a lock so that the membership user can be validated.

UpdateUser(MembershipUser)

更新数据源中有关用户的信息。Updates information about a user in the data source.

ValidateUser(String, String)

验证数据源中是否存在指定的用户名和密码。Verifies that the specified user name and password exist in the data source.

事件

ValidatingPassword

在创建用户、更改密码或重置密码时发生。Occurs when a user is created, a password is changed, or a password is reset.

适用于

另请参阅