user184195
user184195

Reputation: 31

change password without enter the old password in web administration tool

There have any chance to change the password that the user which is created for login without asking the old password.the user management created through web site administration tool.

Upvotes: 3

Views: 2837

Answers (2)

pata
pata

Reputation: 989

i tried @Guido solution and didn't work(method ResetPassword gave not suported exception). What i did:

        string tmptoken = WebSecurity.GeneratePasswordResetToken("UserName");
        WebSecurity.ResetPassword(tmptoken , "newPassword");

Upvotes: 2

Guido Domenici
Guido Domenici

Reputation: 5246

I believe you can do it only programmatically. Steps:

First edit web.config to enable password reset like so:

<?xml version="1.0"?>
<membership defaultProvider="MySqlMembershipProvider">
  <providers>
    <clear />
    <add name="MySqlMembershipProvider" connectionStringName="...." applicationName="..."
    enablePasswordReset="true"
    type="System.Web.Security.SqlMembershipProvider" />
  </providers>
</membership>

Then write some code that will first reset the password thus obtaining the temporary password, then use this temporary password to change to the "final" password:

MembershipUser aspNetUser = Membership.GetUser(username);
string tempPassword = aspNetUser.ResetPassword()
aspNetUser.ChangePassword(tempPassword, newPassword)

Upvotes: 4

Related Questions