Creating user and saving password in clear text.

Posted by Community Admin on 05-Aug-2018 14:19

Creating user and saving password in clear text.

All Replies

Posted by Community Admin on 05-Apr-2014 00:00

Hi, I'm creating users programatically but I'm encountering a problem. What I would like to do is send a user password back when they provide username and email. I want to send the password back as clear text as this is not a high security system and this is allowable.

I've read this on msdn

 

<membership defaultProvider="SqlProvider"
  userIsOnlineTimeWindow="20" hashAlgorithmType="SHA1">
  <providers>
    <add name="SqlProvider"
      type="System.Web.Security.SqlMembershipProvider"
      connectionStringName="SqlServices"
      enablePasswordRetrieval="true"
      enablePasswordReset="false"
      requiresQuestionAndAnswer="true"
      passwordFormat="Clear"
      applicationName="MyApplication" />
  </providers>
</membership>

Where I can change the password format in the membership when creating a user. However, after supplying the applicationName and connectionstringName relevant to my app, it seems that the password is always stored in an encrypted/hashed format. This membership block is placed in my <system.web> section in my web.config file. The way I know it is not being recognized is in my password recovery page when I query a user: 

MembershipUser user = Membership.GetUser(userName, false);
 
try
 
     string password = u.GetPassword();
 
 catch (Exception e)
 
     
 

And call the GetPassword method, I always get an exception, "Password Retrieval Not Enabled". I'm not sure what I'm missing or doing wrong. Would appreciate any help.

This thread is closed