bulk add users

Discussion in 'LiquidFiles General' started by alc18, Jan 11, 2019.

  1. alc18

    alc18 New Member

    Joined:
    Oct 24, 2018
    Messages:
    4
    Likes Received:
    0
    hi! i have to add/invite about 250 external user accounts to our liquidfiles appliance. what's the best way to do that?
    preferably via script or some other automated way. sorry if i was too stupid to rtfm, but i couldn't find anything in the docs.. any help would be appreciated!
     
  2. David

    David Administrator
    Staff Member

    Joined:
    Dec 1, 2015
    Messages:
    781
    Likes Received:
    31
    There is possible to use Admin API to create users accounts. Please have a look at this man page for more details: https://man.liquidfiles.com/admin_api/user_admin_api.html#create_user

    There are many ways how to implement that in various scripting languages. Basically you will need to read email addresses and names of that users from a list and pass that in a loop to the API.
    A basic example how to create external user accounts with a validation send via email in Linux shell script "createusers.sh" can look like this:

    Code:
    #!/bin/sh
    
    server="https://lf.domain.com"
    api_key="ReplaceWithSomeSysAdminAPIkey"
    
    #CSV file where you have list of users, in format:
    #first lastname,user@dom.com
    sourcefile="/tmp/userslist.csv"
    
    #read users from the csv list
    while read usr; do
    usrmail=$(echo $usr | awk -F"," '{ print $2 }' )
    usrname=$(echo $usr | awk -F"," '{ print $1 }')
    
    echo " Creating user: $usrmail"
    #feeding the API
    cat <<EOF | curl -s -X POST --user "$api_key:x" -H 'Content-Type: application/json' -d @- $server/admin/users -k
          {"user":
            {
             "email": "$usrmail",
             "name": "$usrname",
             "group": "external-users",
             "send_password_request": "true",
             "ldap_authentication": "false"
           }
         }
    EOF
    
    done < $sourcefile
    
    The format of the "userslist.csv" file looks like this:
    Code:
    Bob Smith,bob@domain.com,
    Jane,jane@domain.com,
    Joe Dow,joe@domain.com,
    
     
  3. alc18

    alc18 New Member

    Joined:
    Oct 24, 2018
    Messages:
    4
    Likes Received:
    0
    that looks like it's exactly what i need! thank you very much & have a nice weekend!
     

Share This Page