Copied to clipboard

Flag this post as spam?

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


  • jo den 1 post 71 karma points
    Jan 25, 2018 @ 14:25
    jo den
    0

    Programmatically set password for a new User

    Hi,

    I am programmatically creating users (not members!) in umbraco 7.7.3 using the UmbracoContext.Application.Services.UserService like this :

    user = userService.CreateUserWithIdentity(someMailAddress, someMailAddress);
    user.AddGroup((UserGroup)someGroup);
    user.StartMediaId = someMediaId;
    user.StartContentId = SomeContentId;
    userService.Save(user);
    userService.SavePassword(user,password);
    

    The users are correctly created.

    I am not using the method userService.CreateWithIdentity because I need to provide the hashed password, and I don't know how to hash the default password I want to give to those new users.

    I'm trying to use userService.SavePassword() method but I am getting and exception saying : "This provider does not support manually changing the password"

    I have read somewhere that I should set the attribute allowManuallyChangingPassword to true in the web.config, but it is not working for me.

    Any help would be highly appreciated : )

  • Dennis Aaen 4500 posts 18255 karma points admin hq c-trib
    Jan 26, 2018 @ 22:47
    Dennis Aaen
    0

    Hi Jo and welcome to our :)

    Have a look at this blogpost, and see if this can help you a step further.

    http://zachary-wang.com/tips/create-a-umbraco-user-account-programmatically/

    I hope this can help you to solve what you are trying to do.

    /Dennis

Please Sign in or register to post replies

Write your reply to:

Draft