Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

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.

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

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0
Show:
© 2015 Microsoft