+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / Cannot get Password with UserManager

Cannot get Password with UserManager

8 posts, 0 answered
  1. aung maw
    aung maw avatar
    14 posts
    Registered:
    07 Apr 2006
    28 Apr 2009
    Link to this post
    Hi, I'm trying to reset password with UserManager but whenever I try to get the password it gives an error.  web.config file as follows:  Please help. thanks


    <membership defaultProvider="Sitefinity" userIsOnlineTimeWindow="15" hashAlgorithmType="">
                <providers>
                    <clear/>
                    <add name="Sitefinity" connectionStringName="DefaultConnection" type="Telerik.DataAccess.AspnetProviders.TelerikMembershipProvider, Telerik.DataAccess" enablePasswordRetrieval="true" enablePasswordReset="true" requiresQuestionAndAnswer="false" applicationName="/" requiresUniqueEmail="false" passwordFormat="Encrypted" maxInvalidPasswordAttempts="5" passwordAttemptWindow="10" passwordStrengthRegularExpression="" minRequiredPasswordLength="1" minRequiredNonalphanumericCharacters="0"/>
                </providers>
            </membership>



            UserManager um = new UserManager("Sitefinity");
            MembershipUser user;

            user = um.GetUser(txtUserName.Text);
            txtPassword.Text = user.GetPassword();



    String reference not set to an instance of a String.<br>Parameter name: s

    String reference not set to an instance of a String.
    Parameter name: s

    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: System.ArgumentNullException: String reference not set to an instance of a String.
    Parameter name: s

    Source Error:

    Line 171:
    Line 172:        user = um.GetUser(txtUserName.Text);
    Line 173:        txtPassword.Text = user.GetPassword();
    Line 174:
    Line 175:        /*
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    28 Apr 2009
    Link to this post
    Hello aung maw,

    Here is a code that illustrates how you can update an user password.

    UserManager manager = new UserManager(); 
    MembershipUser user = manager.GetUser("customer"); 
    // you can get the password from your textboxes  
    // and pass it through ChangePassword method. 
    //string OldPass = TextBox1.Text; 
    // string NewPass = TextBox2.Text; 
    user.ChangePassword(OldPass, NewPass); 
    manager.UpdateUser(user); 

    I hope this helps.

    Kind regards,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  3. aung maw
    aung maw avatar
    14 posts
    Registered:
    07 Apr 2006
    28 Apr 2009
    Link to this post
    Hi Ivan, that approach is OK but I'm trying to batch update passwords since i'm getting users from another system into Sitefinity.  This GetPassword() method is needed, but it is not working.

    Thanks,
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    29 Apr 2009
    Link to this post
    Hello aung maw,

    The error you are getting is because you are trying to get the password of users that has been registered with Hashed password format. You can get the password using GetPassword method of those users you have registered after you have changed the passwordFormat to Encripted or Clear.

    However, I figured out another problem that is not related to the error you are getting and even you made the changed I suggest above you will not able to get the users' passwords. Helpfully, we will fix the problem for the Hotfix which should be release at the end of the week.

    Let us know if there is anything else that we can do for you.

    Best wishes,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  5. Armysniper
    Armysniper avatar
    126 posts
    Registered:
    03 Mar 2005
    19 Aug 2009
    Link to this post
    Is there a way to convert users who have their password stored in Encrypted to a password that is not encrypted? I thought I could go into the database and change it manually and change the password format there. But I get an error calling GetPassword on users that WERE encrypted.
  6. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    19 Aug 2009
    Link to this post
    Hi Armysniper,

    It is possible if the following requirements are met :  enablePasswordRetrieval="true", you have not automatically generated machine key.

    You can call GetPassword method that should return the password in plain text.

    MembershipUser user = Membership.GetUser("TestUser"); 
    string password = user.GetPassword(); 
    Response.Write(password); 

    Sincerely yours,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  7. Waji
    Waji avatar
    5 posts
    Registered:
    14 Jun 2011
    14 Jun 2011
    Link to this post
    Same Issue with me but I have set machine key and proper membership provider in web.config.
    but I am still face issues.
    <machineKey validationKey="1E7B21306A7B8D73CBB2507C9632552CD34BA90AF540C8637DE25561660C28A7E6D79C83E53862D0CABF95FFBBDB09F458CA466C8884298D93C5D05441D1D021" decryptionKey="D28ECC8FDE1C50DC6E318BB55D7DFBC82CA6D1E76724FC118CA05CCC8DC6D044" validation="SHA1" decryption="AES"/>
    <add name="Sitefinity" connectionStringName="DefaultConnection" type="Telerik.DataAccess.AspnetProviders.TelerikMembershipProvider, Telerik.DataAccess" enablePasswordRetrieval="true" enablePasswordReset="true" requiresQuestionAndAnswer="false" applicationName="/" requiresUniqueEmail="false" passwordFormat="Encrypted" maxInvalidPasswordAttempts="5" passwordAttemptWindow="10" passwordStrengthRegularExpression="" minRequiredPasswordLength="1" minRequiredNonalphanumericCharacters="0"/>
    please guide me for this issue.

    Thanks
  8. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    17 Jun 2011
    Link to this post
    Hi Waji,


    I am not able to replicate this issue using the latest version of Sitefinity 4 - SP1. I even used your machine key.
    Note that you should update the SecurityConfig.config file and the default membership provider.

    <membershipProviders>
            <add passwordFormat="Encrypted" enablePasswordRetrieval="true" name="Default" />
        </membershipProviders>

    Here is the code I used


    Copy Code
    var userObj = Membership.GetUser("admin@2");
    var password = userObj.GetPassword();

    I am not able to replicate the issue in Sitefinity 3.x versions as well.

    Best wishes,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Register for webinar
8 posts, 0 answered