Try this bash script but be sure to set the correct domain name:
list.sh
Code:
#!/bin/bash
MYDOMAIN="domain.com"
NEWPASS="newpass"
TEMPFILE="/tmp/list.txt"
CMDFILE="/tmp/changepw.cmd"
# Create the work files and set appropriate permissions.
touch ${TEMPFILE}
touch ${CMDFILE}
chmod 0600 ${TEMPFILE}
chmod 0600 ${CMDFILE}
# This will create a list of users in Zimbra for the specified domain.
su - zimbra -c "zmprov -l getAllAccounts ${MYDOMAIN} > ${TEMPFILE}"
# This will loop through the users and create a password reset command file.
while read -a LINE ; do
echo "modifyAccount ${LINE[0]] userPassword ${NEWPASS}" >> ${CMDFILE}
done < ${TEMPFILE}
rm ${TEMPFILE} ---------------------------------------------------------------------------------------------------- EDIT for clarification:
Once you create list.sh, make sure you set the correct permissions on the script such as
If you are logged in as the root user, run the command like this:
If you are not the root user, run the command like this:
----------------------------------------------------------------------------------------------------
Now take a look at the /tmp/changepw.cmd file and see if it contains a list of change password commands for all your users in Zimbra. If so, good. We can use that list to reset everyone's accounts. But you might want to go through that file and remove anyone you do not want the password reset...such as admin and the service accounts for spam and whatnot.
Once you are satisfied with the list, simply run the following at the command prompt as the Zimbra user:
Code:
zmprov < /tmp/changepw.cmd
If you plan to run this periodically via a schedule, you can add the following command at the end of the above script:
Code:
su - zimbra -c "zmprov < ${CMDFILE}" But if you do automate it, you need to be sure to also automate the removal of any IDs you manually removed from the list during this process. It would also be a good idea to add
rm ${CMDFILE} to the very end as well to cleanup what was created.
LHammonds