I've just developped a script for automatic distribution list management.
The principle is the following: by adding the keyword "Groups:" to the "Notes" field in the user account, the script will take care of modifying the distribution lists accordingly.
For instance, a Notes field can look like:
> Pete works from home
> Groups: email@example.com firstname.lastname@example.org
The script will make this user a member of the 2 groups and remove him from any other group.
By running the script from cron it is possible to update the groups as often as you want.
To simplify the migration to this system, if the Notes field does not have a "Groups:" label, then nothing changes for that user.
The script is written in Python and needs the package python-ldap to be able to talk with Zimbra's ldap.
It also produces lists of all users and the groups they belong to and all groups and the members they have. For instance:
will list the groups of the users email@example.com and firstname.lastname@example.org.
zmgroup -s ldap://zimbra.whm.com:389 -l email@example.com firstname.lastname@example.org
Will list the same info for all users. The same for groups using the '-g' flag.
zmgroup -s ldap://zimbra.whm.com:389 -l
If no flags are given, the script will generate a zmprov command list to modify the groups according to what it found in the Notes fields. In this version the commands are generated in the file /tmp/updategroups.zm. If it is OK, the file can be run as the user zimbra with the line:
To be able to access the Notes field in LDAP, the user must be a LDAP administrator. Normally this is 'zimbra'. The LDAP root password can be obtained from the file /opt/zimbra/.saveconfig/config.save. The command will look like:
zmprov < /tmp/updategroups.zm
Use the '--help' flag to get a full description of the available features.
zmgroup -s ldap://zimbra.whm.com:389 -u zimbra -p your_ldap_passwd
In a few days, once a few admins gave me their feedback, I will activate the '-x' flag so that the 'zmprov' command is run by this script and a log is sent to the admin. In this way it will be possible to add the command to cron.hourly or cron.daily.
The script can be download from Fichiers WHM.
All your feedback is very welcome.