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


#1

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.


(Alessio Fattorini) #2

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.


#3

Ok, thanks


(Giacomo Sanchietti) #4

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


(Stéphane de Labrusse) #5

Thanks to this unknown benefactor


(Alessio Fattorini) #6

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


(Stefano) #7

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


(Alessio Fattorini) #8

Very good man. Thanks a lot!


(Stéphane de Labrusse) #9

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

that could be tricked in perl