Mass users enroll - Front- & Back-End Development - Front- & Back-End Development - Progress Community
 Front- & Back-End Development

Mass users enroll

  • Mass users enroll
  • 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?

  • 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@", "", "Question", "Answer", true, null, out status);
    user.FirstName = "FirstName";
    user.LastName = "LastName";
    RoleManager roleManager = RoleManager.GetManager();
    roleManager.Provider.SuppressSecurityChecks = true;
    var role = roleManager.GetRole("Customers");
    roleManager.AddUserToRole(user, role);

    Ivan Dimitrov
    the Telerik team

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