Membership.PasswordStrengthRegularExpression 屬性

定義

取得用來評估密碼的規則運算式。

public:
 static property System::String ^ PasswordStrengthRegularExpression { System::String ^ get(); };
public static string PasswordStrengthRegularExpression { get; }
static member PasswordStrengthRegularExpression : string
Public Shared ReadOnly Property PasswordStrengthRegularExpression As String

屬性值

用來評估密碼的規則運算式。

範例

下列程式代碼範例顯示應用程式 Web.config 檔案區段中 的成員資格 組態專案 system.web 。 它會指定應用程式使用 類別的 SqlMembershipProvider 實體來提供成員資格服務,並將 屬性設定 passwordStrengthRegularExpression 為驗證密碼符合下列準則的正規表示式:

  • 長度至少為六個字元。

  • 至少包含一個數位。

  • 至少包含一個特殊 (非英數位元) 字元。

  • 至少包含一個小寫字母。

  • 至少包含一個大寫字母。

如果密碼不符合這些準則,則成員資格提供者不接受密碼。

<membership defaultProvider="SqlProvider"  
  userIsOnlineTimeWindow = "20>  
  <providers>  
    <add  
      name="SqlProvider"  
      type="System.Web.Security.SqlMembershipProvider"  
      connectionStringName="SqlServices"  
      requiresQuestionAndAnswer="true"  
      passwordStrengthRegularExpression="(?=.{6,})(?=(.*\d){1,})(?=(.*\W){1,})(?=.*[a-z])(?=.*[A-Z])"  
      />  
   </providers>  
</membership>  

備註

屬性 PasswordStrengthRegularExpression 會取得正則表示式,用來評估 屬性中所 Provider 指定提供者的密碼複雜度。

屬性PasswordStrengthRegularExpression是使用passwordStrengthRegularExpression成員資格組態項目的 屬性,在應用程式組態中設定。

如需正則表達式的詳細資訊,請參閱 .NET Framework 正則表達式

適用於

另請參閱