System.Web.Security.MembershipProvider.ResetPassword Method

Resets a user's password to a new, automatically generated password.

Syntax

public abstract string ResetPassword (string name, string answer)

Parameters

name
Documentation for this section has not yet been entered.
answer
The password answer for the specified user.

Returns

The new password for the specified user.

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 MembershipProvider.ResetPassword(string, string) method is not guaranteed to pass the regular expression in the MembershipProvider.PasswordStrengthRegularExpression property. However, the random password will meet the criteria established by the MembershipProvider.MinRequiredPasswordLength and MembershipProvider.MinRequiredNonAlphanumericCharacters properties

The MembershipProvider.ResetPassword(string, string) 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 Membership.GeneratePassword(int, int) method.

MembershipProvider.ResetPassword(string, string) ensures that the MembershipProvider.EnablePasswordReset flag is set to true before performing any action. If MembershipProvider.EnablePasswordReset is false, a NotSupportedException exception is thrown.

MembershipProvider.ResetPassword(string, string) also checks the value of the MembershipProvider.RequiresQuestionAndAnswer property. If MembershipProvider.RequiresQuestionAndAnswer is true, MembershipProvider.ResetPassword(string, string) checks the value of the supplied answer parameter against the stored password answer in the data source. If they do not match, a System.Web.Security.MembershipPasswordException exception is thrown.

Requirements

Namespace: System.Web.Security
Assembly: System.Web (in System.Web.dll)
Assembly Versions: 2.0.0.0
Since: .NET 2.0