We are building a force.com sites with authenticated user license. We currently want to load from an existing application around 500,000 users in a csv format with username, password to force.com site as authenticated users.

  1. What is the best way to load this user data with username, password ?

  2. The current application does not store email ids and so we would like to populate with a dummy email id for the first time when we load to salesforce and then we would like to have the users manually update when they login first time. Is there an impact to this?

Thanks Buyan


You'll need to upload these users as contacts and then convert them to users I believe. You can import contacts in the org under Data Management -> Import Accounts/Contacts. Alternatively use a tool such as data loader.

You'll never be able to upload their passwords though, and I really hope you're using the high volume licence or that's going to be an amazingly expensive solution. If you're not absolutely sure that all 500,000 of these users are going to need to use the system, I'd suggest you revise the solution in question.

|improve this answer|||||
  • Thanks for your reply. We really need these 500,000 users to be loaded in salesforce. Can i import users with user name and password using data loader? – buyan kumar Mar 5 '13 at 14:37
  • You can't do password anywhere — at no time can the administrator read a user's password (Incorrect: see response below), much less set it for them. Users you activate will be sent an email which will allow them to set their password the first time they login. – Matt Lacey Mar 5 '13 at 22:09
  • 1
    Just a correction there, an administrator CAN set a user's password. See setPassword method. If you want to do this for multiple users you would need to develop some custom code for that though. – PepeFloyd Mar 5 '13 at 22:58

We loaded 100k portal users by using data loader. We inserted the contacts first and then used the returned contact id in the user insert to link the contact to the portal user. I agree with Matt that you can't set the user's password - we are using Single Sign On for our 100k users so it wasn't an issue.

|improve this answer|||||

Here is some code I used for a migration a while back in order to create portal users. You should be able to modify the license type but I'm not aware that you can specify the password. I marked the users inactive by default to avoid license overages. This code was called from the onAfterInsert event in the contact trigger. If using a batch job, you may have to limit the scope to avoid hitting limits. Remember that once a user license is created, that record will be there forever but will be ignored by licensing if inactive.

This link provides additional user properties: API User object

* Create new partner user in inactive state
@future static void createUser(String contactId, String email, String firstName, String lastName, String userName, String phone, String mobilephone, String profileId,String roleId,String externalId) {
    Database.DMLOptions dmo = new Database.DMLOptions();
    dmo.EmailHeader.triggerUserEmail = false;
    User u = new User(alias = (lastname.length()>8?lastname.substring(0,8):lastname), email=email,
    lastname=lastname, firstname=firstname, Phone=phone, MobilePhone=mobilephone, 
    emailencodingkey='UTF-8', languagelocalekey='en_US',
    localesidkey='en_US', profileid = profileId, contactId=contactId, 
    timezonesidkey='America/Los_Angeles', username=username,ExternalId__c=externalId);
    // Mark user inactive by default, manually activate current designers in UI
    // This will avoid license overages.
    u.IsActive = false;
    try {
        insert u;
    catch(Exception ex) {
        //write to log file here
|improve this answer|||||
  • Thanks for your code and it is really useful. Just an FYI. We can update users with userid and password using a custom apex class . You have to create the account, contact and then use the site.createportaluser method to populate the user data, account and password and this would do the trick. Thanks every one for helping.. – buyan kumar Mar 5 '13 at 23:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.