SqlMembershipProvider.GeneratePassword Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Generates a random password that is at least 14 characters long.
public:
virtual System::String ^ GeneratePassword();
public virtual string GeneratePassword ();
abstract member GeneratePassword : unit -> string
override this.GeneratePassword : unit -> string
Public Overridable Function GeneratePassword () As String
Returns
A random password that is at least 14 characters long.
Examples
The following code example generates a random 10-character password.
SqlMembershipProvider p = (SqlMembershipProvider)Membership.Provider;
string newPassword = p.GeneratePassword();
Dim p As SqlMembershipProvider = CType(Membership.Provider, SqlMembershipProvider)
Dim newPassword As String = p.GeneratePassword()
Remarks
The Membership class provides a GeneratePassword method, which generates a password of a specified size with at least the specified number of non-alphabetic characters. The GeneratePassword method of the SqlMembershipProvider calls the GeneratePassword method of the Membership class to retrieve a random password that is at least 14 characters long. If the MinRequiredPasswordLength property is greater than 14, the password returned will be the length specified in the MinRequiredPasswordLength property.
You can specifically call the GeneratePassword method by referencing the SqlMembershipProvider 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.
Note
The random password created by the GeneratePassword method is not guaranteed to pass the regular expression in the PasswordStrengthRegularExpression property. However, the random password will meet the criteria established by the MinRequiredPasswordLength and MinRequiredNonAlphanumericCharacters properties.
Applies to
See also
.NET
피드백
https://aka.ms/ContentUserFeedback
출시 예정: 2024년 내내 콘텐츠에 대한 피드백 메커니즘으로 GitHub 문제를 단계적으로 폐지하고 이를 새로운 피드백 시스템으로 바꿀 예정입니다. 자세한 내용은 다음을 참조하세요.다음에 대한 사용자 의견 제출 및 보기