Accounts created Report


Script was written do Report on accounts created in a certain time period.

#!/bin/bash
# Zimbra reporting script for Accounts_created_in_Days
# Fred Strauss and Deon Lottering
# How far back to search for, in ldapsearch time format
displaydate=`date -d "30 days ago" +%Y%m%d`"000000Z"
# Get ldap password from zimbra config
ldappass=`/opt/zimbra/bin/zmlocalconfig -s -m nokey zimbra_ldap_password`
# Get ldap dn from zimbra config
ldapdn=`/opt/zimbra/bin/zmlocalconfig -s -m nokey zimbra_ldap_userdn`
# Get ldap URL from zimbra config
ldapurl=`/opt/zimbra/bin/zmlocalconfig -s -m nokey ldap_url`
# ldapsearch and arguments
ldapsearch='/opt/zimbra/bin/ldapsearch'
ldapargs="-LLL -x -H $ldapurl -w $ldappass -D $ldapdn "
# We're only interested in the e-mail address and creation time
ldapattrs="zimbraMailDeliveryAddress createTimestamp"
# ldapsearch for all zimbra accounts that are active, created on or after $displaydate
$ldapsearch $ldapargs -b  "(&(objectclass=zimbraAccount)(!(objectclass=zimbraCalendarResource))(zimbraAccountStatus=Active)(createTimestamp>=$displaydate))" $ldapattrs \
| awk '
# Set Field Seperator to : and initialise our variables
BEGIN {FS=": ";email=0;timestamp=0}
# If line contains the email address, store it
/zimbraMailDeliveryAddress/ {email=$2}
# If line contains the create time, store it in a more readable format
/createTimestamp/ {timestamp=substr($2,0,4) "-" substr($2,5,2) "-" substr($2,7,2)}
# If the line contains dn: we know we are starting with a new entry, print our
# previous data and reset variables
/dn:/ {if (email) print email "," timestamp; email=0; timestamp=0}
# If we reach the end of input, print the last entry
END {if (email) print email "," timestamp}' > /var/log/zimbra-reports/accounts_created_last_30_days_from_`date +%F`.csv
mutt -s "Accounts created in last 30 Days from `date +%F`" -a /var/log/zimbra-reports/accounts_created_last_30_days_from_`date +%F`.csv admin@domain.com < /usr/local/bin/accounts-30days

The file /usr/local/bin/accounts-30days will insert text into the body of your email


Verified Against: unknown Date Created: 8/19/2009
Article ID: https://wiki.zimbra.com/index.php?title=Accounts_created_Report Date Modified: 2015-03-24



Try Zimbra

Try Zimbra Collaboration with a 60-day free trial.
Get it now »

Want to get involved?

You can contribute in the Community, Wiki, Code, or development of Zimlets.
Find out more. »

Looking for a Video?

Visit our YouTube channel to get the latest webinars, technology news, product overviews, and so much more.
Go to the YouTube channel »

Jump to: navigation, search