I currently have a site where I administer users and their account. On my Admin dashboard I want to be able to reset their user's password to whatever I type without knowing the users current password. Below is my coding, I want to either be able to get the user's current password and then change it to whatever I enter in the tb_PWOverride textbox or if that isn't possible I want to reset their password, and get the hashed password and change it to whatever I type in the tb_PWOverride textbox.
the textbox's tb_SecQuest, and tb_SecAns are text boxs I am using to update the security question and answer. That part of the procedure is at least working right now.
protected void btn_profile_Update_Click(object sender, EventArgs args) { try { MembershipUser u = Membership.GetUser(ddl_AllUsers.SelectedValue); //string tempPswd = u.ResetPassword(); ------I would use this line only if I reset string oldPswd = u.GetPassword(); u.ChangePassword(oldPswd, tb_PWOverride.Text); Boolean result = u.ChangePasswordQuestionAndAnswer(tb_PWOverride.Text, tb_SecQuest.Text, tb_SecAns.Text); if (result) Msg.Text = "Password Question and Answer has been updated."; else Msg.Text = "Password Question and Answer was not updated."; } catch (Exception ) { Msg.Text = "Change Failed. Please re-enter your values and try again."; } } }}
If you call ResetPassword() on the User object it should generate a new password and return it to you. You can then feed that into the ChangePassword() method to change it.