Import Many Users


#1

Hi

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?


[Help][Question] Import users from vcard
#2

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


#3

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


#4

Nick

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


#5

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?


#6

Hi,

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
https://www.ablebits.com/office-addins-blog/2013/12/06/add-run-vba-macro-excel/
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
Global Const SW_SHOWMINIMIZED = 2


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 "http://www.mynextcloudaddress.co.uk/"

    ' 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
    
IE.Document.Focus
End With
    
MsgBox "Manually select the desired group your new users will belong to and left click in the Username field"
IE.Document.Focus
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
Loop

MsgBox "Completed!"

End With
End Sub

#7

Hi,
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.