Sometimes we may want to reset the user password for a while, such as setting up a new system or migration from the old mail server and want to clean up old password.
Below are a simple script to bulk-reset Zimbra account password :
[code language=”bash”]
#!/bin/bash
clear
USERS=`su – zimbra -c ‘zmprov -l gaa’`;
for ACCOUNT in $USERS; do
ACC1=`echo $ACCOUNT | awk -F@ ‘{print $1}’`;
ACC=`echo $ACC1 | cut -d ‘.’ -f1`;
if [ $ACC == “admin” ] || [ $ACC == “wiki” ] || [ $ACC == “galsync” ] || [ $ACC == “ham” ] || [ $ACC == “spam” ]; then
echo “Skipping system account, $NAME…”;
else
echo “Modifying $ACCOUNT password…”;
su – zimbra -c “zmprov sp $ACCOUNT NewGeneratedPassword”;
su – zimbra -c “zmprov ma $ACCOUNT zimbraPasswordMustChange TRUE;
echo “Done!”
echo “”
# read anykey
fi
done
echo “Modifying password for all user has been finished successfully”
[/code]
Note : I think it would be better to include some personal ID (part of user name or any fields) into generated-password so all password will be a semi-random password. In my case, I’m using user birth date or part of their name for their generated password to prevent anyone trying to login to any mailbox. It’s not really secure but in my case, it was sufficient for temporary purpose.
Life is our precious gift