System.Web.Security.SqlMembershipProvider.GeneratePassword Method

Generates a random password that is at least 14 characters long.

Syntax

public virtual string GeneratePassword ()

Returns

A random password that is at least 14 characters long.

Remarks

The System.Web.Security.Membership class provides a Membership.GeneratePassword(int, int) method, which generates a password of a specified size with at least the specified number of non-alphabetic characters. The SqlMembershipProvider.GeneratePassword method of the System.Web.Security.SqlMembershipProvider calls the Membership.GeneratePassword(int, int) method of the System.Web.Security.Membership class to retrieve a random password that is at least 14 characters long. If the SqlMembershipProvider.MinRequiredPasswordLength property is greater than 14, the password returned will be the length specified in the SqlMembershipProvider.MinRequiredPasswordLength property.

You can specifically call the SqlMembershipProvider.GeneratePassword method by referencing the System.Web.Security.SqlMembershipProvider class directly from the Membership.Provider property of the System.Web.Security.Membership class.

The generated password only contains alphanumeric characters and the following punctuation marks: !@#$%^&*()_-+=[{]};:<>|./?. No hidden or non-printable control characters are included in the generated password.

Note:

The random password created by the SqlMembershipProvider.GeneratePassword method is not guaranteed to pass the regular expression in the SqlMembershipProvider.PasswordStrengthRegularExpression property. However, the random password will meet the criteria established by the SqlMembershipProvider.MinRequiredPasswordLength and SqlMembershipProvider.MinRequiredNonAlphanumericCharacters properties.

Requirements

Namespace: System.Web.Security
Assembly: System.Web (in System.Web.dll)
Assembly Versions: 2.0.0.0
Since: .NET 2.0