Export (0) Print
Expand All

MembershipProvider.ResetPassword Method

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

Namespace:  System.Web.Security
Assembly:  System.Web (in System.Web.dll)

public abstract string ResetPassword(
	string username,
	string answer
)

Parameters

username
Type: System.String

The user to reset the password for.

answer
Type: System.String

The password answer for the specified user.

Return Value

Type: System.String
The new password for the specified user.

Takes, as input, a user name and a password answer and generates a new, random password for the specified user.

NoteNote:

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.

For an example of a MembershipProvider implementation, see Implementing a Profile Provider.

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0, 2.0

Community Additions

ADD
Show:
© 2014 Microsoft