Script Import-users - How to add user to a group?

The script (http://docs.nethserver.org/en/latest/accounts.html#import-users) works perfectly but is it possible to add fields matching groups

User1 depends of group Group1
User2 depends of group Group2

I would like to test with a lot of users and I’ll take a long time to associate them to the groups.

No way to do this now, maybe in the future. A customer asked this feature yet, on payment, hence it will probably be released on NethServer as well.

Ok, thanks

When the customer will pay, the feature will be available to all, for sure!

1 Like

Thanks to this unknown benefactor

1 Like

I moved a post to a new topic: New selector for groups

well

a script like this one:

while read p; do
#echo $p
user=`echo $p | cut -d \| -f 1`
group=`echo $p | cut -d \| -f 2`

actmembers=$(db accounts getprop $group Members)

if [ $actmembers ]; then
db accounts setprop $group Members $actmembers,$user
else
db accounts setprop $group Members $user 
fi

signal-event group-modify $group

done <import.lst

and a file like

user1|group1
user1|group2
user2|group2

should do the trick

tested only a bit, YMMV

2 Likes

Very good man. Thanks a lot!

the script to import is there /usr/share/doc/nethserver-directory-2.2.0/import_users

that could be tricked in perl