SqlMembershipProvider.EnablePasswordRetrieval 属性

定义

获取一个值,指示 SQL Server 成员资格提供程序是否配置为允许用户检索其密码。Gets a value indicating whether the SQL Server membership provider is configured to allow users to retrieve their passwords.

public:
 virtual property bool EnablePasswordRetrieval { bool get(); };
public override bool EnablePasswordRetrieval { get; }
member this.EnablePasswordRetrieval : bool
Public Overrides ReadOnly Property EnablePasswordRetrieval As Boolean

属性值

如果成员资格提供程序支持密码检索,则为 true;否则为 falsetrue if the membership provider supports password retrieval; otherwise, false. 默认值为 falseThe default is false.

示例

下面的代码示例演示 ASP.NET 应用程序的 web.config system.web文件的节中的成员身份元素。The following code example shows the membership element in the system.web section of the Web.config file for an ASP.NET application. 它指定应用程序的SqlMembershipProvider实例,并启用密码检索。It specifies the application's SqlMembershipProvider instance and enables password retrieval.

<membership defaultProvider="SqlProvider" userIsOnlineTimeWindow="20">  
  <providers>  
    <add name="SqlProvider"  
      type="System.Web.Security.SqlMembershipProvider"  
      connectionStringName="SqlServices"  
      enablePasswordRetrieval="true"  
      enablePasswordReset="false"  
      requiresQuestionAndAnswer="false"  
      passwordFormat="Encrypted"  
      applicationName="MyApplication" />  
  </providers>  
</membership>  

注解

Hashed如果将PasswordFormat属性设置为,则用户将无法从数据库中检索其现有密码。If the PasswordFormat property is set to Hashed, a user will not be able to retrieve his or her existing password from the database. Hashed密码格式提供密码值的单向编码。The Hashed password format provides one-way encoding of password values. 密码使用随机生成的 salt 值进行哈希处理,并与存储在用于身份验证的数据库中的值进行比较。Passwords are hashed with a randomly generated salt value and compared to values stored in the database for authentication. 不能对哈希值进行编码以检索原始密码值。Hashed values cannot be unencoded to retrieve the original password value.

Hashed EnablePasswordRetrieval如果属性设置为,并且设置为trueProviderException则在初始化提供程序时引发。 PasswordFormatIf the PasswordFormat property is set to Hashed, and EnablePasswordRetrieval is set to true, a ProviderException is thrown when the provider is initialized.

适用于

另请参阅