I am trying to get EXPIRE_DATE of pwd for an active directory user in ubuntu. I can get information about the user with lslogins user but no information about password expire dates that are set in AD. and sudo chage -l user does not work: chage: user 'user' does not exist in /etc/passwd is there something in realmd (sssd) that can give med such information?


Using net (it will fail if the domain controller is not capable of returning the expiration date):

net ads user info {username}@{domain} -S {servername} -U {username}

or using rpcclient (source) ($USER means current user):

RPCLOOKUPID=$(rpcclient -P -c "lookupnames $USER" dc1)
USERDCID=$(echo "$RPCLOOKUPID" | grep -e '[0-9]\{4,9\} ' -o)
QUERYUSER=$(rpcclient -P -c "queryuser $USERDCID" dc1)
EXPDATE=$(echo "$QUERYUSER" | grep 'Password must change Time' | cut -d > ":" -f 2,3,4,5 | sed -e 's/^[[:space:]]*//')
| improve this answer | |
  • Gratz. The date should be i. – Rinzwind Jul 31 '18 at 16:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.