More in this section
Forums / Sitefinity SDK / Mass users enroll

Mass users enroll

The forums are in read-only mode. In case that you want to directly contact the Progress Sitefinity team use the support center. In our Google Plus group you can find more than one thousand Sitefinity developers discussing different topics. For the Stack Overflow threads don’t forget to use the “Sitefinity” tag.
2 posts, 0 answered
  1. Oleg
    Oleg avatar
    7 posts
    02 Mar 2009
    02 Feb 2011
    Link to this post
    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?

  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    12 Sep 2017
    02 Feb 2011
    Link to this post
    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.
2 posts, 0 answered