Can I create multiple users from a text file?

I can’t find the information anywhere can I automatically create users using a text or cvs file?

I don’t think so.
But you can link to an LDAP user database…

1 Like

Thanks for the tip. Do you know of any good documentation about this?

It has a very generic interface…
If you’ve ever done this before with any other app (linking to LDAP) you will feel at home…

Nextcloud docs are quite extensive
https://docs.nextcloud.com/server/18/admin_manual/configuration_user/user_auth_ldap.html

You could write a quick and dirty bash script to create them with OCC.

https://docs.nextcloud.com/server/18/admin_manual/configuration_server/occ_command.html#user-commands

1 Like

I like @KarlF12’s approach since its really simple and easy to do. It probably wouldn’t scale well if you had over 20 users, but it would be good for a limited number

LDAP is more feature rich and you could probably implement something like openldap using docker and the openldap container: https://github.com/osixia/docker-openldap. I’ve recently integrated a very primitive openldap server for another project. Word of caution here – and this comes from someone who is a complete NOOB to ldap – writing user and group filters to extract information from the database is very difficult. There isn’t a lot of tutorials on the subject, and the ones I found didn’t really help me resolve my issues. Finally with some help found on some gitter channel I was able to find a solution. The guys helping me all had experience with Windows Active Directory (which is similar to ldap) and they said ldap isn’t a “beginner project”. I was very greatful for their help.

It’s far easier to implement a flat file technique as discussed above. Good luck to you whatever direction you choose to pursue.

LDAP is a great thing, but the OP didn’t even say he had LDAP. He has a CSV.

What I like to do in a situation like that is put it in Notepad++ and do a regex replace to transform the list into a list of actual commands and then just paste it. This actually works really well with a CSV because it’s already formatted and delimited.

With so many useful OSS apps - Wordpress, Nextcloud (ownCloud), jitsi, BBB, etc. - and others making them work together securely - privacyIDEA, Keycloak, etc. - I believe it is a good idea to use an external user database. And LDAP/AD is an obvious candidate for this role… Because all the listed apps support it…

All commercial (virtual) firewalls - Cisco, Juniper, PaloAlto, etc. - support it.
Sophos has one NGFW for home that is free for up to 10 devices.
You can have state of the art 2FA (push, Yubikeys, TOTP) for free…

Does this make sense at home for half a dozen users or so? Probably not…

But for anything a dozen or more it makes perfect sense to have it external, centralized.
Even if simply in a standalone Windows Server 2016/2019 form.

And everything else in your homelab use it…

@anon71540698

I don’t disagree with what you’ve said – however unless you’ve worked with ldap before, the filter syntax can be daunting. I’m betting you’ve worked with ldap/AD before so it’s probably not as big of deal.

Here is an example of what I’m talking about:

username_attribute: cn
additional_users_dn: ou=users
users_filter: (&(cn={input})(objectClass=inetOrgPerson))
additional_groups_dn: ou=groups
groups_filter: (&(member={dn})(objectclass=groupOfNames))

(Took me a while to come up with all that mess for my database to work).

Thanks a lot guy @kevdog @KarlF12 @anon71540698 I will look into both solutions since I have to manage multiple nextcloud instances ragging from 5 to more than 500 users so the journey’s gonna be a long one …

@maeglin If you have Active Directory or LDAP already in place at any of them, I would highly recommend leveraging it in Nextcloud. Central user management is almost always preferable and saves untold time spent on user management over the little extra it takes to link it on the front end.

Hi, nearly same req., spreadsheet with ~ 30 email adresses to be added as users to my Nextcloud.
I’m going to read a book about openLDAP, but this is a future project, 600 pages, maybe next vacation :slight_smile:

So for now just some small questions: I’m fine with writing a small perl script, reading the spreadsheet and generating occ user:add commands from it. NC docs about occ user:add say

user:add [--password-from-env] [--display-name[="..."]] [-g|--group[="..."]] uid

My questions:
Is it possible to let the password empty, like in GUI, to get the newly added user informed by email that he or she is now a Nextcloud user, with a link to securely set his or her own pw? Or maybe setting by script a dummy password, any chance to reset by user, after being informed by email?

1 Like