ActiveDirectoryMembershipProvider.PasswordAttemptWindow 属性

定义

获取时间长度,在该时间间隔内对提供有效密码或密码答案的连续失败尝试次数进行跟踪。

public:
 virtual property int PasswordAttemptWindow { int get(); };
public override int PasswordAttemptWindow { get; }
member this.PasswordAttemptWindow : int
Public Overrides ReadOnly Property PasswordAttemptWindow As Integer

属性值

对未能提供有效密码或密码答案的连续尝试次数进行跟踪的时间长度(以分钟为单位)。 默认值为 10 分钟。 如果两次失败尝试之间的间隔大于 PasswordAttemptWindow 属性设置,则 ActiveDirectoryMembershipProvider 实例将每次失败尝试都视为第一次失败尝试。

例外

在初始化 PasswordAttemptWindow 实例之前,已尝试访问 ActiveDirectoryMembershipProvider 属性。

示例

下面的代码示例演示了一个 Web.config 条目,该条目将实例配置为 ActiveDirectoryMembershipProvider 锁定在 10 分钟时间范围内尝试输入密码答案的三次失败的用户。 如果用户被锁定,则 15 分钟内可能不会再尝试回答密码问题。

<configuration>  
  <connectionStrings>  
    <add name="ADService" connectionString="LDAP://ldapServer/" />  
  </connectionStrings>  
  <system.web>  
    <membership defaultProvider="AspNetActiveDirectoryMembershipProvider">  
      <providers>  
        <add name="AspNetActiveDirectoryMembershipProvider"   
          type="System.Web.Security.ActiveDirectoryMembershipProvider,   
          System.Web, Version=2.0.3600, Culture=neutral,  
          PublicKeyToken=b03f5f7f11d50a3a"  
          maxInvalidPasswordAttempts="3"  
          passwordAttemptWindow="10"  
        passwordAnswerAttemptLockoutDuration="15" />  
      </providers>  
    </membership>  
  </system.web>  
</configuration>  

注解

属性 PasswordAttemptWindow 与 属性结合使用, MaxInvalidPasswordAttempts 以帮助防止不需要的源通过重复尝试猜测成员身份用户的密码或密码答案。 当用户尝试登录、更改其密码或重置其密码时,在指定的时间范围内只允许一定数量的连续尝试。 时间窗口的长度由 PasswordAttemptWindow 属性指定,该属性标识在无效尝试之间允许的分钟数。 如果用户重置其密码的连续失败尝试次数等于 属性中 MaxInvalidPasswordAttempts 存储的值,并且自上次无效尝试以来经过的时间小于为 PasswordAttemptWindow 属性指定的分钟数,则用户帐户将锁定属性中包含的 PasswordAnswerAttemptLockoutDuration 分钟数。 如果当前失败尝试与上次失败尝试之间的间隔大于 PasswordAttemptWindow 属性设置,则当前无效尝试将计为第一次尝试。 如果在达到允许的最大无效尝试次数之前提供了有效的密码答案,则无效密码答案尝试的计数将设置为零。 如果在达到允许的最大无效尝试次数之前提供了有效密码,则无效密码尝试计数和无效密码答案尝试计数将设置为零。

建议将 PasswordAnswerAttemptLockoutDuration 属性设置为与帐户锁定持续时间相同的值,该值指定为 Active Directory 配置中失败登录尝试的最大次数。 这将为用户呈现一致的自动锁定行为,无论用户是因登录尝试失败还是密码答案错误而被锁定。

属性 PasswordAnswerAttemptLockoutDurationpasswordAttemptWindow 应用程序的配置文件中使用 成员资格元素 (ASP.NET 设置架构) 元素的属性进行设置。 如果未在应用程序的配置文件中设置 属性,则 PasswordAnswerAttemptLockoutDuration 属性设置为默认值 10 分钟。

适用于

另请参阅