Allow space in SqlMembershipProvider password

96 views Asked by At

Are spaces not allowed in the default password format for SqlMembershipProvider, or have I done something else wrong? If they aren't allowed, why is that?

<add name="SqlServerMembershipProvider" 
             type="System.Web.Security.SqlMembershipProvider, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" 
             connectionStringName="MyConnectionStringName" 
             requiresQuestionAndAnswer="false" 
             applicationName="MyApplicationName" 
             requiresUniqueEmail="false" 
             passwordFormat="Hashed" 
             maxInvalidPasswordAttempts="5" 
             minRequiredPasswordLength="6" 
             minRequiredNonalphanumericCharacters="0" 
             passwordAttemptWindow="10" 
             passwordStrengthRegularExpression="" />
1

There are 1 answers

0
James On BEST ANSWER

I think the problem here is the passwordStengthRegularExpression is an empty string - I can't say for sure because I can't see anything in the docs with regards to how it's checked. However, if you were to do something like

var match = Regex.Match("My password string", "");

It would return no matches, the only string that would match a pattern of "" is..."". If you aren't interested in providing a password strength mechanism then omit the attribute completely or alternatively use a "capture all" type regex e.g.

passwordStrengthRegularExpress=".+"