The explain scripts zimbra ldap reset last login time
File /tmp/email the contain accounts email, you want change last login time.
cat /tmp/emailThe output as bellow
[email protected]when you running script, then zimbraLastLogonTimestamp change the last login the current date
[email protected]
DATE=$(date +%Y%m%d)The output as bellow
20170726
[email protected] with zimbraLastLogonTimestamp: 20170511135742.260Z to changed zimbraLastLogonTimestamp: 20170726000000.000Z
My scripts zimbra ldap reset last login time
#!/bin/bash
#HuuPV
rm -f /tmp/account_DN
DATE=$(date +%Y%m%d)
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"
for MAIL in $(cat /tmp/email)
do
$LDAPSEARCH "(&(!(zimbraIsSystemResource=TRUE))(mail=$MAIL)(&(objectclass=zimbraAccount)))" dn | sed 's/dn: //g' | sed '/^\s*$/d' | sed 's/^\ //g'>>/tmp/account_DN
done
for j in $(cat /tmp/account_DN)
do
ldapmodify -x -H ldap://$LDAP_HOST -D $LDAP_USERDN -w $LDAP_PASSWORD <<EOF
dn: $j
changetype: modify
replace: zimbraLastLogonTimestamp
zimbraLastLogonTimestamp: $DATE000000.000Z
EOF
done
The conclusion
zimbra ldap reset last login time for list all account email. To change last login time quickly!
Thanks for reading zimbra ldap reset last login time My blog Effortless Zimbra Mail Management: Unleashing the Power of Linux Commands, How-To, and Bash Scripts I hope this is useful.