Browse Source

zimbra Import account with CSV ver 1.0

pull/1/head
Sébastien Faton 3 years ago
parent
commit
adb4848e4e
  1. 24
      zimbra/import_export_accounts/import_account_with_csv.sh

24
zimbra/import_export_accounts/import_account_with_csv.sh

@ -0,0 +1,24 @@
#!/bin/bash
DATE=$(date)
OLDIFS=$IFS
IFS=','
File_Name="accounts.csv"
Out_log='/tmp/outfile.log'
echo "$DATE - To create account Email" | tee $Out_log
echo "Account, Password, First_Name, Last_Name, DisplayName, zimbraMailHost" | tee -a $Out_log
while read Acount_Email Password First_Name Last_Name Display_Name Mailbox
do
echo "$Acount_Email, $Password, $First_Name, $Last_Name, $Display_Name, $Mailbox" | tee -a $Out_log
echo ""
Uid=$(echo $Acount_Email | cut -d '@' -f1)
Domain=$(echo $Acount_Email | cut -d '@' -f2)
su - zimbra -c "zmprov -l gaa | grep '\b$Uid'@$Domain"
if [ $? -eq 0 ] ; then
echo "$Acount_Email exits"
else
su - zimbra -c "zmprov ca '$Acount_Email' '$Password' givenName '$First_Name' sn '$Last_Name' displayName '$Display_Name' zimbraMailHost '$Mailbox' zimbraPasswordMustChange TRUE " >>$Out_log
fi
done < ${File_Name}
IFS=$OLDIFS
#option "zimbraPasswordMustChange TRUE" pour l'obligation de changement du mot de passe lors de la premiere connexion
Loading…
Cancel
Save