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
zimbra ldap reset last login time





The explain scripts zimbra ldap reset last login time


File /tmp/email the contain accounts email, you want change last login time.
cat /tmp/email
The output as bellow
huupv01@mail.huuphan.com
huupv02@mail.huuphan.com
when you running script, then zimbraLastLogonTimestamp change the last login the current date
DATE=$(date +%Y%m%d)
The output as bellow
20170726




For example
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

Popular posts from this blog

zimbra some services are not running [Solve problem]

Bash script list all IP addresses connected to Server with Country Information

How to Install Python 3.13