Hashed passwords cannot be recovered. Either set the password format to a different type, or set the enablePasswordRetrieval parameter to false

I have a website and now I want to get passwords.

I use it:

<add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider"
             connectionStringName="TravelChamps" 
enablePasswordRetrieval="true"
             enablePasswordReset="true"
             requiresQuestionAndAnswer="false"
             requiresUniqueEmail="false" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" 
             minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" applicationName="/"             
             />

And this error occurs:

Configurable settings are invalid: Hashed password cannot be obtained. Either set the password format to a different type, or set the enablePasswordRetrieval parameter to false.

If I use it:

<add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider"
             connectionStringName="TravelChamps" enablePasswordRetrieval="false"
             enablePasswordReset="true"
             requiresQuestionAndAnswer="false"
             requiresUniqueEmail="false" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" 
             minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" applicationName="/"             
             />

I get the following error:

An exception occurred that caused a password to be received: this membership provider is not configured to support password searching.

I am completely confused.

Any suggestion where I can start working?

+5
source share
5 answers

, . ( , , .) .

+3

, ( ), , .

( asp net):

1. web.config, // :

enablePasswordRetrieval="true"<br/>
passwordFormat="Encrypted"

:

<membership>
  <providers>
    <clear/>
    <add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider"     connectionStringName="maindb"
         enablePasswordRetrieval="true" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false"
         maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10"
         applicationName="/" passwordFormat="Encrypted" />
  </providers>
</membership>

2. validationKey decryptionKey. NET API:

:

public static class RNGCrypto_MachineKey
{
    public static string getRandomKey(int bytelength)
    {
        byte[] buff = new byte[bytelength];
        RNGCryptoServiceProvider rng = new RNGCryptoServiceProvider();
        rng.GetBytes(buff);
        StringBuilder sb = new StringBuilder(bytelength * 2);
        for (int i = 0; i < buff.Length; i++)
            sb.Append(string.Format("{0:X2}", buff[i]));
        return sb.ToString();
    }
}

:

string key64 = RNGCrypto_MachineKey.getRandomKey(64);
string key32 = RNGCrypto_MachineKey.getRandomKey(32);

3.Again, web.config system.web:

    <machineKey validationKey="paste here the key64 string" decryptionKey="paste here the key32 string" validation="SHA1"/>

( machinkey msdn)

4. , :

Membership.GetUser(username).GetPassword();
+10

, , ( reset ). , reset , :

MembershipUser usr = Membership.GetUser("username", false);
string resetPassword = usr.ResetPassword();
usr.ChangePassword(resetPassword, "yayiknowthepassword");
+2

, , :

, . "reset", . , - - - , , , .

+1

, . . *: - , webconfig enablePasswordRetrieval = "true" passwordFormat = "Encrypted"

MembershipUser user = Membership.GetUser("username", false);
string resetPassword = user.ResetPassword();
user.ChangePassword(resetPassword, "new password to set");

''"

0

All Articles