jump to navigation

Changing a member’s Password Question and Password Answer December 16, 2008

Posted by mcamail2002 in Uncategorized.
trackback

In some situations, the Customer Service department may wish to modify a member’s Password Question and Password Answer. This is easily accomplished if passwords are encrypted or maintained in clear text. For hashed passwords, however, a password-reset is also required since the provider method, ChangePasswordQuestionAndAnswer, requires the member’s password which is not retrievable. By setting “requiresQuestionAndAnswer” to false, “enablePasswordRetrieval” to true and “enablePasswordReset” to true in web.config, the member’s Password Question and Password Answer may be reset:

Clear text :  Call the GetPassword method with the username and without the need for a password answer to retrieve the password. Now, armed with the password, call ChangePasswordQuestionAndAnswer to set the Password Question and Password Answer to a desired value.

Encrypted    Call the GetPassword method with the username and without the need for a password answer to retrieve the password. Now, armed with the password, call ChangePasswordQuestionAndAnswer to set the Password Question and Password Answer to a desired value.

              Hashed:    Call the ResetPassword method with the username and without the need for a password answer to reset the password to a new random value. Using the newly generated password, call ChangePasswordQuestionAndAnswer to set the Password Question and Password Answer to a desired value. Optionally call ChangePassword to set the password to a more user-friendly value.

string password = Membership.Providers[providerName].GetPassword(currentUser,string.Empty); 
if (!string.IsNullOrEmpty(password))

{
if (Membership.Provider.ChangePasswordQuestionAndAnswer(currentUser, password, txtSecurityQuestion.Text.Trim(), txtSecurityAnswer.Text.Trim()))
FailureText.Text =
“Password Question and Answer changed.”;
else
FailureText.Text = “Change failed. Please re-enter your values and try again.”;
} 

 

Comments»

No comments yet — be the first.