abc0012383

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::
#!/usr/bin/env bash
NUM1=10000000
NUM2=3600
NUM3=24
NUM4=90

if [ -s yad ];then
        > yad
fi

/usr/bin/ldapsearch -H ldap://xxx.com -Y GSSAPI -N -b ou=xxx,dc=xxx,dc=com '(&(objectClass=user)(userAccountControl=512))'|grep pwdLastSet|awk -F ":" '{print $2}'> day

while read line
        do
                DAY=`expr $line / $NUM1 / $NUM2 / $NUM3`
                nowSec=`date +%s`
                pSk=11644473600
                totalSec=$[ $nowSec+$pSk ]
                dayLi=`expr $totalSec / $NUM2 / $NUM3`
                LAST=$[ ($DAY+$NUM4)-$dayLi ]
                echo $LAST >> yad
done < day

/usr/bin/ldapsearch -H ldap://xxx.com -Y GSSAPI -N -b ou=xxx,dc=xxx,dc=com '(&(objectClass=user)(userAccountControl=512))'|grep userPrincipalName|awk -F ":" '{print $2}' > email

paste -d " " email yad > join

while read i k
        do
        if [[ "$k" -lt 5 && "$k" -gt 0 ]];then
         echo -e "Hi,\nYour xxx domain passord will exprie within $k days, please consider change your password ASAP.\n" | mail -s 'Password Expiration Reminder' $i

                fi
done < join

exit 0

 

posted on 2024-08-27 09:35  abc0012383  阅读(7)  评论(0编辑  收藏  举报