[ASP.NET 2.0 Security FAQs]目錄
原文連結
翻譯:2005-12-10 by Jackie Lin
你可以在membership裡配置minRequiredPasswordLength, minRequiredNonAlphanumericCharacters, 和 passwordStrengthRegularExpression 屬性,來強制使用安全性高的密碼.
安全性高的密碼可以用來防止壓力攻擊(brute force attacks)和字典攻擊(dictionary attacks).
SqlMembershipProvider 和ActiveDirectoryMembershipProvider 的預設密碼強度配置為:最少7個字元,其中最少有1個非字母數位字元 .
如果你是在活動目錄(AD)中使用ActiveDirectoryMembershipProvider , 你的域密碼組策略(domain password policy)會預設的被使用, 不過你可以在你的程式裡配置membership以覆蓋相關的配置. 同樣的, 如果你是在ADAM中使用ActiveDirectoryMembershipProvider , 你的本地密碼組策略(local password policy)會預設被使用, 你也可以配置membership覆蓋相關的配置.
你可以使用Regex來配置特別的密碼強度規則, 或者你也可以配置密碼中數字、字元、字母的最小最大長度.
使用Regex
<membership>
<providers>
<add passwordStrengthRegularExpression=
"^(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{8,10}$" />
</providers>
</membership>
使用最小的非字母數字字元長度
<membership>
<providers>
<add minRequiredPasswordLength=10 minRequiredNonalphanumericCharacters=2 />
</providers>
</membership>
譯者註:以上均在web.config檔案中配置
更多資訊
更多關於強密碼的資訊請參考:"How To: Protect Forms Authentication in ASP.NET 2.0" http://msdn.microsoft.com/library/en-us/dnpag2/html/PAGHT000012.asp