How to import many user accounts at the same time

Hi, all:

I just installed the owncloud and I need to import the user accounts into the owncloud.

However, I found there is no way to import amount of user accounts in the same time in the web portal. Is that any possible way to do this? Now I have a XML file to store all the user accouts. The version of owncloud is 10.0.2.

Thank you.

Can anyone help me this?
Cause I have got a huge number of users, I can not create them once a time.

Thank you.

Recommend to use LDAP and import there. Alternatively you can use the provisioning API and write a script which does the provisioning for you.

Thank you for your reply.

The API seems not support importing many users at the same time.

How to use LDAP to import? I am a fresh in computer. Can you guide me how to do it?

Thank you.

Pure scripting approach:

export OC_PASS=initial_pass_alice
./occ user:add alice --display-name='Alice Cooper' --email='' --group=music --password-from-env
export OC_PASS=initial_pass_bob
./occ user:add bob --display-name='Bobby Brown' --email='' --group=music --password-from-env

Thank you for your reply and sorry for my late reply.

I am not sure that I understand your idea.(Sorry for my fresh in computer). Is that meaning I still need to type all usernames password email group in script? That is a long list..Maybe I misunderstand your suggestions.

Maybe this code helps you to import a bulk of users from csv file to owncloud database.
First, you may have all the users data in a CSV file separated by commas with this columns: username_1,display name,password,email,group
Like this example:

valar.ainur,Javier Camacho,1234abcd,,users

Then, connect to your server via terminal and run this bash script in your owncloud home directory, in my case is: /srv/www/htdocs/owncloud

input = "import_users_from_file.csv"
var_apache_user = www-data
var_path_owncloud = /srv/www/htdocs/owncloud
while read -r line
echo "Line: ${line}"
var_username = $(echo "${line}" | cut -d "," -f1)
var_name = $(echo "${line}" | cut -d "," -f2)
var_password = $(echo "${line}" | cut -d "," -f3)
var_email = $(echo "${line}" | cut -d "," -f4)
var_group = $(echo "${line}" | cut -d "," -f5)
set -e
export OC_PASS = $var_password
su -s /bin/sh ${var_apache_user} -c "php ${var_path_owncloud}/occ user:add --display-name='${var_name}' --group='${var_group}' --password-from-env --email='${var_email}' -- '${var_username}'"

done < "$input"
exit 0