共用方式為


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 組態中失敗登入嘗試次數上限所指定的帳號鎖定持續時間相同的值。 無論使用者因為登入嘗試失敗或密碼答案不正確而遭到鎖定,這都會呈現一致的自動鎖定行為。

屬性 PasswordAnswerAttemptLockoutDuration 是在應用程式的組態檔 passwordAttemptWindow 中使用 成員資格元素的 屬性設定, (ASP.NET Settings Schema) 元素。 如果未在應用程式的組態檔中設定屬性,則 PasswordAnswerAttemptLockoutDuration 屬性會設定為預設值 10 分鐘。

適用於

另請參閱