In case of a lost or forgotten user password, the administrator should be able to access and reset it in the Admin part of Sitefinity. However, when an administrator
has forgotten/lost the password, there are two approaches with which to proceed. One is to add code to the project, the other is to change a setting in the
database.
Adding Code
One approach for resetting the password is by running the following code:
|
Copy Code |
|
MembershipProvider prov = UserManager.Default.MembershipProvider;
prov.ResetPassword("admin", "");
|
 |
The UserManager is part of the Telerik.Security assembly. Another option is to substitute UserManager in
the above code with Telerik.Security.UserManager. |
There are two properties of the membership provider that should also be changed in the web.config file. The enablePasswordReset should be set
to true, and the requiresQuestionAndAnswer to false.
| web.config |
Copy Code |
|
<system.web>
...
<membership defaultProvider="Sitefinity" ...
...
<add name="Sitefinity" connectionStringName="DefaultConnection"
type="Telerik.DataAccess.AspnetProviders.TelerikMembershipProvider,
Telerik.DataAccess" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" applicationName="/"
requiresUniqueEmail="false" passwordFormat="Hashed" maxInvalidPasswordAttempts="5" passwordAttemptWindow="10"
passwordStrengthRegularExpression="" minRequiredPasswordLength="1" minRequiredNonalphanumericCharacters="0"/>
|
Changing a Setting in the Database
The second approach for resetting the password is to make a modification in the database.
The hashed format of a password is stored in the database table Telerik_Users. In order to access the password, the password format should be
changed - the PasswordFormat value should be set from 1 to 0 (put into "Clear" mode) so that the password is
saved as plain text in the table. After executing this, the new format of the password will be saved in the Password field. Copy this string and paste it
into the password field when logging in into the Admin part of Sitefinity.
Next, go to Administration -> Users, and click the Profile link of the administrator user. Then, click the Reset password
link (see Figure 1). Copy the newly generated password. Click Save user info. Go to the link My Profile (situated in the upper right
corner of the screen, next to the Logout link).

Figure 1
Then, choose the Change password link (see Figure 2). Paste the generated password and enter your new password in the second and third text fields. Click
Change Password.

Figure 2
Afterwards, go back to the database and change back the PasswordFormat field value of the admin user to 1.
See Also