For 3.5
Make a file called users.csv
jfoo,John,Foo,password,
jbar,Jack,Bar,password,
fart,Fred,Art,password,
dick,Dave,Ick,password,
sudo bash bulkusers
bulkusers script
#!/bin/bash
INPUT=users.csv
OLDIFS=$IFS
IFS=,
[ ! -f $INPUT ] && { echo "$INPUT file not found"; exit 99; }
while read username givenname surname password
do
echo "$username $givenname $surname $password"
samba-tool user add "$username" "$password" --given-name="$givenname" --surname="$surname"
done < $INPUT
IFS=OLDIFS
samba-tool user add -h will give a full list of parameters
also you can use ldbmodify and this could add any other ldap info that samba-tool doesn't provide for.
Here example setting mail address.
#!/bin/bash
LDIF=my.ldif
INPUT=users.csv
OLDIFS=$IFS
IFS=,
[ ! -f $INPUT ] && { echo "$INPUT file not found"; exit 99; }
while read username givenname surname password
do
rm /tmp/$LDIF
echo "$username $givenname $surname $password"
samba-tool user add "$username" "$password" --given-name="$givenname" --surname="$surname"
echo "dn: CN="$givenname" "$surname",CN=Users,DC=office,DC=zentyal,DC=lan
changetype: modify
add: mail
mail: "$username"@zentyal.lan" > /tmp/$LDIF
ldbmodify -H /var/lib/samba/private/sam.ldb -b DC=office,DC=zentyal,DC=lan /tmp/$LDIF
rm /tmp/$LDIF
done < $INPUT
IFS=OLDIFS
You will have to edit the base DN, from my test install to however you have set yours "DC=office,DC=zentyal,DC=lan" my test fqdn is zent1.office.zentyal.lan realm is office.zentyal.lan.