Mass users enroll

Posted by Community Admin on 05-Aug-2018 11:05

Mass users enroll

All Replies

Posted by Community Admin on 02-Feb-2011 00:00

Hi.
We need to create customer's accounts from our ERP system (backend MS SQL database) in Sitefinity 4.
I created role, "Customers" and now need to create user accounts within this role.
Could you please advice how can I do this quickly?

Thanks,

Posted by Community Admin on 02-Feb-2011 00:00

Hello Oleg,

You can do this programmatically. Below is a sample code. First you have to create the user. Then you have to add it to your role.

var userManager = UserManager.GetManager("Default");
System.Web.Security.MembershipCreateStatus status;
userManager.Provider.SuppressSecurityChecks = true;
var user = userManager.CreateUser("user1", "user111@", "user1@test.com", "Question", "Answer", true, null, out status);
user.FirstName = "FirstName";
user.LastName = "LastName";
userManager.SaveChanges();
 
 
RoleManager roleManager = RoleManager.GetManager();
roleManager.Provider.SuppressSecurityChecks = true;
var role = roleManager.GetRole("Customers");
roleManager.AddUserToRole(user, role);
roleManager.SaveChanges();


Regards,
Ivan Dimitrov
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.

This thread is closed