zimbra ldap reset last login time
How to change last login time for all accounts in zimbra ldap. I'm running scripts on zimbra ldap with zimbra account. To use zimbra 8.6
File /tmp/email the contain accounts email, you want change last login time.
For example
huupv01@mail.huuphan.com with zimbraLastLogonTimestamp: 20170511135742.260Z to changed zimbraLastLogonTimestamp: 20170726000000.000Z
My scripts zimbra ldap reset last login time
zimbra ldap reset last login time for list all account email. To change last login time quickly!
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
huupv01@mail.huuphan.comwhen you running script, then zimbraLastLogonTimestamp change the last login the current date
huupv02@mail.huuphan.com
DATE=$(date +%Y%m%d)The output as bellow
20170726
huupv01@mail.huuphan.com 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!
Comments
Post a Comment