Hi,
When I create a user through the command line specifying the groups in which it has to be added, Nextcloud creates new groups instead of adding the user to existing ones.
In this example:
sudo -u www-data php occ user:add --display-name=“Layla Smith”
–group=“users” --group=“db-admins” layla
Nextcloud would create a new group called “users” and another one called “db-admins” and add the user to them even if there are groups previously created with the same names.
Does anyone know how to make this work properly? I am using NC 25. Thanks!
According to the docs, that should work 
You could try to use the group command to list the groups and check what groupid they return: Using the occ command — Nextcloud latest Administration Manual latest documentation and also try to add users this way.
Yes, this is how I did it, but there must be something missing in the documentation…
Thanks!
Did you try it via the group commands I linked? (not the user command, there’s a dedicated group command).
If it does not work, can you show the group:list command and the command you’re using to add users?
Late response, but maybe helpful for someone else looking for possible answers.
I stumbled upon the same issue. After some research, including using the group:list command I noticed the following:
-
Renaming a group does not change its internal name, i.e. the one relevant to the occ command. One of my groups had an internal name that was different from the name displayed in the web interface. AFAICT, the internal name was the original name given. The group was then renamed, but the internal name did not change. Easy to reproduce: create a group “Test”, then run occ group:list. You’ll see the group “Test” listed. Then, through the web interface, rename the group to “Test group”. When you run occ group:list, you will again see “Test” listed, not “Test group”.
-
I had a group name that had an apostrophe in it. As I went through a spreadsheet software to prepare a long list of users and their groups, the apostrophe (') was changed into a typographic apostrophe (’ ). Thus the name was not exactly the same, and NC was right to create a new group.