MembershipProvider.PasswordStrengthRegularExpression 属性

定义

获取用于计算密码的正则表达式。Gets the regular expression used to evaluate a password.

public:
 abstract property System::String ^ PasswordStrengthRegularExpression { System::String ^ get(); };
public abstract string PasswordStrengthRegularExpression { get; }
member this.PasswordStrengthRegularExpression : string
Public MustOverride ReadOnly Property PasswordStrengthRegularExpression As String

属性值

用于计算密码的正则表达式。A regular expression used to evaluate a password.

示例

下面的示例显示了应用程序的 web.config 文件的system.web部分中的成员资格元素(ASP.NET 设置架构)配置元素。The following example shows the membership Element (ASP.NET Settings Schema) configuration element in the system.web section of the application's Web.config file. 它指定应用程序使用SqlMembershipProvider类的实例来提供成员身份服务,并passwordStrengthRegularExpression将特性设置为一个正则表达式,该表达式用于验证密码是否满足以下条件:It specifies that the application use an instance of the SqlMembershipProvider class to provide membership services, and sets the passwordStrengthRegularExpression attribute to a regular expression that validates that the password meets the following criteria:

  • 超过7个字符。Is greater than seven characters.

  • 包含至少一个数字。Contains at least one digit.

  • 包含至少一个特殊字符(非字母数字)。Contains at least one special (non-alphanumeric) character.

如果密码不符合这些条件,则成员资格提供程序不接受该密码。If the password does not meet these criteria, the password is not accepted by the membership provider.

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

注解

属性获取用于计算MembershipProvider对象的密码复杂性的正则表达式。 PasswordStrengthRegularExpressionThe PasswordStrengthRegularExpression property gets the regular expression used to evaluate password complexity for the MembershipProvider object.

PasswordStrengthRegularExpression应用程序配置中, passwordStrengthRegularExpression使用成员资格元素(ASP.NET 设置架构)配置元素的属性设置该属性。The PasswordStrengthRegularExpression property is set in the application configuration using the passwordStrengthRegularExpression attribute of the membership Element (ASP.NET Settings Schema) configuration element.

适用于

另请参阅