Change password without entering old password in web administration tool

It is possible to change the password that the user created to log in does not ask for the old password. User management is created using the website administration tool.

+3
source share
2 answers

I believe that you can only do this programmatically. Steps:

First edit web.config to enable the reset password as follows:

<?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 a code that will reset the password first, receiving a temporary password, then use this temporary password to go to the "final" password:

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

@Guido ( ResetPassword ). :

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

Source: https://habr.com/ru/post/1719263/


All Articles