Get All Account in Zimbra [CLI] ++

Probably most all zimbra administrator known this command

$ zmprov -l gaa

but we will get all account that listed in zimbra including all system account such as spam, wiki, ham, etc.  Sometime we want to exclude them for some purpose such as policy for force change password or change some account attribute.

We can exclude with ease by using grep command after it (pipe), so the command will be like this.

$ zmprov -l gaa | grep -v "^\(admin@\|wiki@\|spam.*@\|ham.*@\|virus.*@\)"

command above excluding all account that begin with admin@, wiki@, spam, ham and virus. if you want to exclude another one just add some in regex pattern.

The most sophisticated way is using ldapsearch command with some filter for excluding system account eg: spam,ham (zimbraIsSystemAccount=TRUE)  and account that has admin rights (zimbraIsAdminAccount=TRUE)

$ ldapsearch -H ldap://zimb.mail.ok:389 -x -D uid=zimbra,cn=admins,cn=zimbra -w pass  '(&(!(|(zimbraIsSystemAccount=TRUE)(zimbraIsAdminAccount=TRUE))))' mail | grep mail:

make sure that ldap connection url (-H) and ldap admin password same as your zimbra environment.

$ zmlocalconfig -s zimbra_ldap_password ldap_url

Leave a comment