SimpleMembershipProvider.ResetPassword Method
Resets the password for a user account to a new, automatically generated password.
Namespace: WebMatrix.WebData
Assembly: WebMatrix.WebData (in WebMatrix.WebData.dll)
Syntax
'Declaration
Public Overrides Function ResetPassword ( _
username As String, _
answer As String _
) As String
'Usage
Dim instance As SimpleMembershipProvider
Dim username As String
Dim answer As String
Dim returnValue As String
returnValue = instance.ResetPassword(username, _
answer)
public override string ResetPassword(
string username,
string answer
)
public:
virtual String^ ResetPassword(
String^ username,
String^ answer
) override
abstract ResetPassword :
username:string *
answer:string -> string
override ResetPassword :
username:string *
answer:string -> string
public override function ResetPassword(
username : String,
answer : String
) : String
Parameters
- username
Type: System.String
The user account to reset the password for.
- answer
Type: System.String
The answer to the security question for the new user.
Return Value
Type: System.String
The new password for the specified user account.
Exceptions
Exception | Condition |
---|---|
NotSupportedException | EnablePasswordReset is false. |
MembershipPasswordException | answer does not match the security answer for the user account in the membership table and RequiresQuestionAndAnswer is true. |
Remarks
Note
The password generated by the ResetPassword(String, String) method is not guaranteed to pass the test specified by the PasswordStrengthRegularExpression property. However, the generated password will meet the criteria established by the MinRequiredPasswordLength and MinRequiredNonAlphanumericCharacters properties.
The ResetPassword(String, String) method updates the user account information in the membership database using the new password value and returns the new password as a string.
Note
If the SimpleMembershipProvider class has been initialized using a call to the WebSecurity.InitializeDatabaseConnection() method, this method is not supported and will throw a NotSupportedException exception. However, if the WebSecurity.InitializeDatabaseConnection() method has not been called, and if you have configured your site to use the standard ASP.NET membership provider, this method is passed through to the standard membership provider. For more information, see the SimpleMembershipProvider class overview.