MembershipProvider.ResetPassword(String, String) 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.
Resets a user's password to a new, automatically generated password.
public:
abstract System::String ^ ResetPassword(System::String ^ username, System::String ^ answer);
public abstract string ResetPassword (string username, string answer);
abstract member ResetPassword : string * string -> string
Public MustOverride Function ResetPassword (username As String, answer As String) As String
Parameters
- username
- String
The user to reset the password for.
- answer
- String
The password answer for the specified user.
Returns
The new password for the specified user.
Examples
For an example of a MembershipProvider implementation, see Implementing a Profile Provider.
Remarks
Takes, as input, a user name and a password answer and generates a new, random password for the specified user.
Note
The random password created by the ResetPassword 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
The ResetPassword method updates the user information in the data source with the new password value and returns the new password as a string. A convenient mechanism for generating a random password is the GeneratePassword method.
ResetPassword ensures that the EnablePasswordReset flag is set to true
before performing any action. If EnablePasswordReset is false
, a NotSupportedException exception is thrown.
ResetPassword also checks the value of the RequiresQuestionAndAnswer property. If RequiresQuestionAndAnswer is true
, ResetPassword checks the value of the supplied answer parameter against the stored password answer in the data source. If they do not match, a MembershipPasswordException exception is thrown.
Applies to
See also
反馈
https://aka.ms/ContentUserFeedback。
即将发布:在整个 2024 年,我们将逐步淘汰作为内容反馈机制的“GitHub 问题”,并将其取代为新的反馈系统。 有关详细信息,请参阅:提交和查看相关反馈