Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Gordon Saxby 1461 posts 1883 karma points
    Jul 24, 2012 @ 01:10
    Gordon Saxby
    0

    Change User password via API

    I am trying to change the password of a User (not Member) in a UserControl but it does not seem to be working.

    I found this post http://our.umbraco.org/forum/developers/api-questions/10247-Is-MemberShipHelper-out-of-45 and used the same / similar code but the password doesn't change ... ?

  • Lennart Stoop 304 posts 842 karma points
    Jul 24, 2012 @ 09:45
    Lennart Stoop
    0

    Hi Gordon,

    If I remember correctly you can get the user from the membership provider and update the password directly, much like this:

    MembershipUser user = Membership.Providers[UmbracoSettings.DefaultBackofficeProvider].GetUser("login", true);

    user.Password = "newpassword";

    user.Save();

     

    Grtz

    L

     

     

  • Gordon Saxby 1461 posts 1883 karma points
    Jul 24, 2012 @ 10:07
    Gordon Saxby
    2

    OK ... problem solved!

    The issue was that the password was not being hashed when assigned / saved. The above code is one option I tried but the password was entered into the database as plain text. The solution was found here http://our.umbraco.org/wiki/reference/api-cheatsheet/users,-user-types-and-permissions/add-user-with-hashed-password

    I have implemented similar code and it appears to work fine!

                var u = new User(LoginName);
                u.Password = HashPassword(newPwd);
                u.Save(); 
Please Sign in or register to post replies

Write your reply to:

Draft