SqlMembershipProvider.RequiresQuestionAndAnswer 属性

定义

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

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

属性值

如果密码重置和检索需要提供密码提示问题答案,则为 true;否则为 falsetrue if a password answer is required for password reset and retrieval; otherwise, false. 默认值为 trueThe default is true.

示例

下面的代码示例演示 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 configures it to require a password answer for password reset or retrieval.

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

注解

在检索或重置用户密码时,需要密码提示问题和答案可以提供额外的安全层。Requiring a password question and answer provides an additional layer of security when retrieving or resetting a user's password. 创建用户名时,用户可以提供稍后可用于检索或重置忘记密码的问题和答案。When creating a user name, a user can supply a question and answer that can later be used to retrieve or reset a forgotten password. 如果属性和属性都是false,则RequiresQuestionAndAnswer属性的值是不相关的。 EnablePasswordRetrieval EnablePasswordResetIf the EnablePasswordReset property and the EnablePasswordRetrieval property are both false, the value of the RequiresQuestionAndAnswer property is irrelevant.

有关详细信息,请参阅 ResetPasswordGetPasswordFor more information, see ResetPassword and GetPassword.

适用于

另请参阅