I am working on forgot password functionality. I use default sitecore user provider. How I can update user password programmatically?

Is it possible to change password by manipulation with object of Sitecore.Security.Accounts.User class?

  • Yes you can pass the Name property of the User object into the Membership.GetName(string) method. If that's what you mean. Nov 18 '16 at 9:54

As you can't get the old password, you should use the reset functionality:

var user = System.Web.Security.Membership.GetUser(@"domain\username");
var oldPassword = user.ResetPassword();
var newPassword = "Mynewstrongpassword1!";
user.ChangePassword(oldPassword, newPassword);

To change the password, you need to work with the Membership user. But as Dražen mentioned, you can get use the Name property of the Sitecore.Security.Accounts.User object in the GetUser method.

  • what type of user?
    – Vlad
    Nov 18 '16 at 9:34
  • updated code example..
    – Gatogordo
    Nov 18 '16 at 9:38
  • thanks. can you please also provide answer to my second question?
    – Vlad
    Nov 18 '16 at 9:42
  • done - although Dražen already did too
    – Gatogordo
    Nov 18 '16 at 10:10

There is a way in case you need to build User Management tools for an internal support team. Let's say an admin needs to reset a password for a Content Author you can take advantage of Sitecore PowerShell Extensions.


Set-UserPassword -Identity michael -NewPassword pass123 -OldPassword b

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.