Import Many Users


I am new to OwnCloud err I mean NextCloud (I like where the Nextcloud project is going and its attitude)

I want to import multiple users at once, is there a way to do this say with a CSV files?

Not really, but there is a console command ./occ user:add which you can call from a bash script which loops over the csv

Thank Might be too difficult for me, I guess its manual for me or perhaps the contact app can do this?


Unless you already have such a script you would be willing to share

I would like to push this feature request again!
I also have a large number of users to add which I store as excel-sheet at the moment, so the import of csv files would be nice! Also the possibility to sync between the contacts app and the user list would be really nice!

Maybe it’s possible to import csv files to the contacts app an sync them to the user list?


This is a feature I also badly needed as I have about 200 users to create! I have previously had sucess with excel macros that work with Internet Explorer to complete fields in online forms, and, realising that the NEXTCLOUD admin pages are essentially web pages with forms, I thought I would try the same method…

I was delighted to discover that it worked :slightly_smiling_face:

At the bottom of this post is the code required for the excel macro.
NOTE the script will fail if your passwords do not meet your NEXTCLOUD minimum password policy!

When creating your own macro in an excel workbook …

enter usernames in column A
enter passwords in column B

update the URL of the your NextCloud hosting within the code

Run macro

Here follows the code
This needs to go into a module - see
for some basic instructions

Have fun!

Declare Function apiShowWindow Lib "user32" Alias "ShowWindow" _
            (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long

Global Const SW_MAXIMIZE = 3
Global Const SW_SHOWNORMAL = 1

Public Function Nz(ByVal Value, Optional ByVal ValueIfNull = "")
    Nz = IIf(IsNull(Value), ValueIfNull, Value)
End Function

' Tested with Office 2010 and NextCloud 10

Sub CreateUsersAndPasswordsNextCloud()
Dim IE As Object
Dim usercount As Integer

Set IE = CreateObject("internetexplorer.application")
IE.Visible = 1
apiShowWindow IE.hwnd, SW_MAXIMIZE
    With IE
    'Replace the URL below with your NEXTCLOUD address - don't forget the / at the end!
    .Navigate ""

    ' Waits for i.e. to become ready
    Do While IE.ReadyState = 4: DoEvents: Loop   'Do While
    Do Until IE.ReadyState = 4: DoEvents: Loop   'Do Until

    .Visible = False
    .Visible = True
End With
MsgBox "Manually select the desired group your new users will belong to and left click in the Username field"
With IE
usercount = 1
Do While Nz(Sheet1.Cells(usercount, 1), "") <> ""
'the Application.Wait line ensures that there is enough time for the sendkeys command to execute
'to speed up the script you can try commenting out these lines
Application.Wait (Now + TimeValue("0:00:01"))
Application.SendKeys Sheet1.Cells(usercount, 1)
Application.Wait (Now + TimeValue("0:00:01"))
Application.SendKeys "{TAB}"
Application.Wait (Now + TimeValue("0:00:01"))
Application.SendKeys Sheet1.Cells(usercount, 2)
Application.Wait (Now + TimeValue("0:00:01"))
'Application.SendKeys "{TAB}"hbriggs 1209865hdg

'Application.Wait (Now + TimeValue("0:00:01"))
Application.SendKeys "{RETURN}"
Application.Wait (Now + TimeValue("0:00:01"))

'moves to next user password pair
usercount = usercount + 1

MsgBox "Completed!"

End With
End Sub

Can you share the ready excel file with macros inside
And how about Display Name on same excel file, email ?
I need to add more columns in sheet of excel file?

And please tell me is possible to run on Firefox,Chome or other browser.


I’m looking for a feature to create bulk users from Admin panel in Nextcloud 15. Or can you please share the ready excel file with macros inside?
And how about Display Name on same excel file, email?


We have solved such a problem with connecting Nextcloud to Freeipa ldap and importing users with bash script from csv.




declare -i index=0
declare -a group_list

while IFS=’,’ read -r -a LINE; do
if [ $index -gt 0 ]
echo “adding user: ${LINE[2]}”
ipa user-add ${LINE[2]} --first="${LINE[0]}" --last="${LINE[1]}" --email="${LINE[3]}" --employeenumber="${LINE[6]}"
done < $FILE

while IFS=’,’ read -r -a LINE; do
if [ $index -gt 0 ]
echo “Setting password: ${LINE[2]}”
X=$(expect -c "spawn ipa user-mod ${LINE[2]} --password
expect "Password: "
send “${LINE[5]}\n”
expect “verify: "
send “${LINE[5]}\n”
expect “Modified””)
echo “$X”
done < $FILE

while IFS=’,’ read -r -a LINE; do
if [ $index -gt 0 ]
echo “adding: ${LINE[2]} to ${LINE[8]}”
ipa group-add-member ${LINE[8]} --users=${LINE[2]}
done < $FILE
exit 0

Hi, I made a Python CLI tool for that:

Just paste your data correctly into the users.csv and config.xml and execute the program.
This tool is executed locally and uses the Nextcloud API on your instance.

It’s not a beauty, but it does the job :slightly_smiling_face:

Hi @dexter2k,
Just used your tool. It seems to work great but I manage to import only one user, the script then returns errors. Here are some screenshots:
Shared with CloudApp
Shared with CloudApp
Any idea to fix this?

Hi Frank,
the error says that the logo file does not exist. Did you check that?

Do you use the .py script or the precompiled executable?
Maybe you can try the precompiled version with a Windows PC. Seems to work best and is the most current build.

Good luck!

Hi @dexter2k,

Thanks for your message.

Yes I checked the logo file and it’s here. Screenshot :
I tried to put assets folder on the server with no success :

I also get the error message “groupadminlist is not defined”:
Do I have to fill in the “subadmin” column? I don’t necessarily need to, at least not for all users.

I used the Unix executable, open it with Terminal on a Mac :

Thank you in advance for your answer.


Sorry @dexter2k
Just run the precompile with Terminal and got this error :
So I added “# coding: utf-8” at the beginning of the file :

Now got this one :

I don’t see what else to do…

Hi Frank.

The precompiled version for Mac was from February. Some of those bugs were fixed in the Windows and Python version. I deleted these old versions from the server.

Please use the Windows version. It’s the easiest way. I don’t have a current Mac OS to compile a new Mac package.

Alternatively install the python packages yourself and run the .py script.
I have documented the dependencies here:

Regarding other errors you get: did you edit the users.csv with Apple Numbers?
That software switches ; and , for field separation. Please open the users.csv file in a normal text editor, to check the content. There could be trailing ;;;;;; which you should delete.
Try the software with a minimal example like given in the original users.csv.

Oh my goodness. I bought an 11-inch PC for 300,-€ a month ago to give training courses on office tools. 25 years I’ve been on the Mac. Never thought I’d be so happy I bought one. The script works like a charm.
Thank you so much for looking into my problem. If it wasn’t for the covid, I would have hugged you!:smiley:
Have a great day!!

Great! Glad I could help you!
Have fun with your Nextcloud :slight_smile:

Hey @dexter2k
Just a last thing:
We don’t want to send an email to the students and prefer to give them only the URL of the login page so that they can click on “Forgotten password” and generate their own password. However, if I don’t check the “Send email to created users” box, the email fields are empty after import and therefore no password reset is possible.
Do you have a solution ?

@dexter2k here’s a screenshot :
Shared with CloudApp

Cool, you just made clear why this is happening:


I will look into it.