GeneratePassword Method

ActiveDirectoryMembershipProvider.GeneratePassword Method ()

 

Generates a random password.

Namespace:   System.Web.Security
Assembly:  System.Web (in System.Web.dll)

public virtual string GeneratePassword()

Return Value

Type: System.String

A random password.

The GeneratePassword method of the ActiveDirectoryMembershipProvider class calls the GeneratePassword method of the Membership class to retrieve a random password. The password length is set to the value of the MinRequiredPasswordLength property. The password length can never be less than 14.

You can specifically call the GeneratePassword method by referencing the ActiveDirectoryMembershipProvider class directly from the Provider property of the 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.

The generated password will contain at least the number of non-alphanumeric characters specified in the MinRequiredNonAlphanumericCharacters property. The generated password will not be tested with the regular expression in the PasswordStrengthRegularExpression property.

System_CAPS_noteNote

The ActiveDirectoryMembershipProvider class does not generate passwords that match complexity requirements set in the directory. It is possible to generate a random password that fails the password complexity rules set by the directory.

.NET Framework
Available since 2.0
Return to top
Show:
© 2016 Microsoft