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 in the UmbracoMembershipProvider element to true in the web.config, but it is not working for me.
Any help would be highly appreciated : )
UmbracoMembershipProvider
refers to Members, not Users, so in this case, you should change this value for UsersMembershipProvider
.
You could also try to set RawPasswordValue
property for newly created user:
user.RawPasswordValue = (Membership.Providers["UsersMembershipProvider"] as UsersMembershipProvider).HashPasswordForStorage(password);