Bulk User creation Script?

#1

Has anyone here already created a script for entering in bulk users from a speadsheet or db?

Cheers
Phil

0 Likes

#2

Found this https://groups.google.com/forum/#!searchin/farcry-dev/user$20import|sort:date/farcry-dev/xtdi6zIxu3Y/oPxOjZn7R7QJ
Will update on how I go :slight_smile:

0 Likes

#3

Ok well the above wasn’t much help, but I managed to Frankenstein some existing code I’ve used in the past while looking at the editCLIENTUDUser.cfm for inspiration.
The below function only requires a struct containing {firstname,lastname,username,password}

function createUser(struct stNewUser){
    var oUser = createobject("component","#application.packagepath#.types.farUser");
    var oProfile = createobject("component","#application.packagepath#.types.dmProfile");
    var stUser = {};
    var stProfile = {};
// create struct for farUser
stUser.locked = 0;
stUser.lockedBy = '';stUser.objectID = createUUID();
stUser.datetimeCreated = now();
stUser.lastUpdatedBy = 'farcry_CLIENTUD';
stUser.datetimeLastUpdated = now();
stUser.createdBy = 'farcry_CLIENTUD';
stUser.ownedby = ''; 
stUser.typeName = 'farUser';    	
stUser.userid = stNewUser.username;
stUser.password = stNewUser.password;
stUser.userstatus = "active";
stUser.aGroups = ['E689D131-A4A0-21F0-45AB44EC3AB144CD'];// Member objectid in my table

oUser.setData(stProperties=stUser,user='admin');
// get the newly created user so we can attach a profile to it
stUser = oUser.getData(objectid=stUser.objectID);

// create struct for dmProfile
stProfile.locked = 0;
stProfile.lockedBy = '';

stProfile.objectID = createUUID();
stProfile.datetimeCreated = now();
stProfile.lastUpdatedBy = 'farcry_CLIENTUD';
stProfile.datetimeLastUpdated = now();
stProfile.createdBy = 'farcry_CLIENTUD';
stProfile.ownedby = '';

stProfile.typeName = 'dmProfile';
stProfile.firstname = stNewUser.firstname;
stProfile.lastname = stNewUser.lastname;
stProfile.label = stProfile.firstname & ' ' & stProfile.lastname;
stProfile.BRECEIVEEMAIL = 0;
stProfile.username = "#stUser.userid#_CLIENTUD";
stProfile.userdirectory = "CLIENTUD";

oProfile.setData(stProperties=stProfile,user='admin');

}// end function
0 Likes