{"id":7,"date":"2008-05-16T09:11:00","date_gmt":"2008-05-16T03:41:00","guid":{"rendered":"http:\/\/guganeshan.com\/blog\/?p=7"},"modified":"2009-12-18T14:02:03","modified_gmt":"2009-12-18T08:32:03","slug":"resetting-asp-net-membership-password-when-the-user-has-forgotton-the-answer-for-the-security-question","status":"publish","type":"post","link":"https:\/\/guganeshan.com\/blog\/resetting-asp-net-membership-password-when-the-user-has-forgotton-the-answer-for-the-security-question.html","title":{"rendered":"Resetting asp.net membership password when the user has forgotton the answer for the security question!"},"content":{"rendered":"<p>Here is the scenario&#8230; a web application has been implemented with the standard user management features&#8230; can create new users, the admin approves the users, can recover passwords and change security question + answer bla bla bla<\/p>\n<p>What happens if a user forgets the password?&#8230; simple, just goto the password recovery page and answer the security question and get the new password in the email.<\/p>\n<p>But what if he\/she doesn&#8217;t remember the answer for the security question???<!--more--><\/p>\n<p>Well, this is what happened exactly today. Although there were some solutions on the net, they required you to create a temporary Membership provider in the config etc.. which I didn&#8217;t like doing.<\/p>\n<p>But for my joy, I found <a href=\"http:\/\/geekswithblogs.net\/TimH\/archive\/2005\/09\/28\/55414.aspx\">this post<\/a> that gave me the idea. Although it is not a clean solution to the problem, it was what I wanted for the urgent need of resetting the password (since this won&#8217;t happen too often)<\/p>\n<p>The <a href=\"http:\/\/geekswithblogs.net\/TimH\/archive\/2005\/09\/28\/55414.aspx\">post<\/a> says that you have to replace the password hash and salt with the password hash and salt of a user whose password you know! What a simple idea. Well, whose password do I know?? mine of course!<\/p>\n<p>So this is what I did:<\/p>\n<ol>\n<li>Changed my password to something like password_999<\/li>\n<li>Replaced the user&#8217;s (who doesn&#8217;t remember the security answer) password hash and salt with my hash and salt<\/li>\n<li>Changed my password back<\/li>\n<li>Gave him &#8216;password_999&#8217; as the password, which he obviously will have to change once he logged in<\/li>\n<\/ol>\n<p>A more hassle-free solution would be to always have a dummy user account in the Membership database, which we can keep locked or as unapproved. And to make things even simpler, we can deploy an admin&#8217;s page that can accept the user name and replace the password hash and salt (copied from the dummy user account)&#8230;  thanks to <a href=\"http:\/\/geekswithblogs.net\/TimH\/Default.aspx\">Tim Huffam<\/a><\/p>\n<!-- AddThis Advanced Settings generic via filter on the_content --><!-- AddThis Share Buttons generic via filter on the_content -->","protected":false},"excerpt":{"rendered":"<p>Here is the scenario&#8230; a web application has been implemented with the standard user management features&#8230; can create new users, the admin approves the users, can recover passwords and change security question + answer bla bla bla What happens if a user forgets the password?&#8230; simple, just goto the password recovery page and answer the [&#8230;]<!-- AddThis Advanced Settings generic via filter on get_the_excerpt --><!-- AddThis Share Buttons generic via filter on get_the_excerpt --><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7,9],"tags":[23,30,29,68],"class_list":["post-7","post","type-post","status-publish","format-standard","hentry","category-programming","category-troubleshooting","tag-net","tag-asp-net","tag-tips","tag-troubleshooting"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/guganeshan.com\/blog\/wp-json\/wp\/v2\/posts\/7","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/guganeshan.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/guganeshan.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/guganeshan.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/guganeshan.com\/blog\/wp-json\/wp\/v2\/comments?post=7"}],"version-history":[{"count":4,"href":"https:\/\/guganeshan.com\/blog\/wp-json\/wp\/v2\/posts\/7\/revisions"}],"predecessor-version":[{"id":88,"href":"https:\/\/guganeshan.com\/blog\/wp-json\/wp\/v2\/posts\/7\/revisions\/88"}],"wp:attachment":[{"href":"https:\/\/guganeshan.com\/blog\/wp-json\/wp\/v2\/media?parent=7"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/guganeshan.com\/blog\/wp-json\/wp\/v2\/categories?post=7"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/guganeshan.com\/blog\/wp-json\/wp\/v2\/tags?post=7"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}