How to check zimbra account status

How to check zimbra account status? How to know zimbra account status pending. How to know zimbra account status active, closed, locked, maintenance. In my post, one bash script get all zimbra account status and zmaccts commands another.
Links to below you maybe likes:
zimbra custom spamassassin rules
How to create auto Bcc for Recipient mails for Zimbra 8.6
How to add spam filters on zimbra 8.6
How to create auto Bcc for sender mails for Zimbra 8.6
list accounts that has not logged in for the last x days in zimbra

How to check zimbra account status

Method 1: To bash script use zimbra ldap check zimbra account status.

# sed ':a;N;$!ba;s/\n/ /g' file : command line
# :a create a label 'a'
# N append the next line to the pattern space
# $! if not the last line, ba branch (go to) label 'a'
# s substitute, /\n/ regex for new line, / / by a space, /g global match (as many times as it can)
# sed will loop through step 1 to 3 until it reach the last line, getting all lines fit in the pattern space where sed will substitute all \n characters
LDAP_HOST=`/opt/zimbra/bin/zmlocalconfig ldap_host | cut -d\ '' -f3`
LDAP_PASSWORD=`/opt/zimbra/bin/zmlocalconfig -s zimbra_ldap_password | cut -d\ '' -f3`
LDAP_USERDN=`/opt/zimbra/bin/zmlocalconfig zimbra_ldap_userdn | cut -d\ '' -f3`
LDAPSEARCH="/opt/zimbra/bin/ldapsearch -D "$LDAP_USERDN" -w$LDAP_PASSWORD -H ldap://$LDAP_HOST -LLL -o ldif-wrap=no"
$LDAPSEARCH "(&(objectClass=zimbraAccount)($ZIMBRA_ACCOUNT_STATUS=*)(mail=*$DOMAIN))" $ZIMBRA_ACCOUNT_STATUS | sed 's/ou=people,//g' | sed 's/dn: uid=/:/g' | sed 's/,dc=/@/' | sed 's/,dc=/./g' | sed 's/,dc=/./g' | sed ':a;N;$!ba;s/\n/ /g' | sed "s/$ZIMBRA_ACCOUNT_STATUS: //g" | sed 's/:/\n/g

Method 2: To use zmaccts command line check zimbra account status.

$ zmaccts | grep active | grep @mail.huuphan.local | awk '{print $1}'


  1. What if the most desired document or letter is lost or theft along with the letterbox? The result might be catastrophic sometime! So, it should be the foremost duty to ensure the safety of your documents outside the door. A secure and heavy duty locking mailbox can do this. We were in search of the best secure mailbox.

  2. Second "sed 's/,dc=/./g'" in method #1 is unnecessary because the first one already replaced all ",dc=" with dots.
    Also, you lost the closing apostrophe of mehod #1

  3. Also, first and last calls to sed could be combined into single command to avoid unnecessary invocations of sed:

    $LDAPSEARCH "(&(objectClass=zimbraAccount)(!($ZIMBRA_ACCOUNT_STATUS=active))(mail=*$DOMAIN))" $ZIMBRA_ACCOUNT_STATUS \
    | sed 's/ou=people,//g;s/dn: uid=/:/g;s/,dc=/@/;s/,dc=/./g' \
    | sed ':a;N;$!ba;s/\n/ /g' \
    | sed "s/$ZIMBRA_ACCOUNT_STATUS: //g;s/:/\n/g"

    Newlines are inserted for clarity. See: the sed allows to specify several expressions in one command, and these expressions must be separated by semicolons.
    I'm in no way criticize your style. I just suggesting some kind of optimizations. That is the spirit of the open-source: learn from each other, teach each other.


Post a Comment

Popular posts from this blog

zimbra some services are not running [Solve problem]

Bash script list all IP addresses connected to Server

How to install php7 on centos 6