Skip to content

Instantly share code, notes, and snippets.

@pmbuko
Last active August 29, 2015 14:24
Show Gist options
  • Save pmbuko/132bfd7b45c806d84bab to your computer and use it in GitHub Desktop.
Save pmbuko/132bfd7b45c806d84bab to your computer and use it in GitHub Desktop.
This script should return the date and time of a logged in OS X user's Active Directory password expiration. Please test and let me know if you get an accurate value.
#!/bin/bash
USER=$(/usr/bin/python -c \
'from SystemConfiguration import SCDynamicStoreCopyConsoleUser;\
print SCDynamicStoreCopyConsoleUser(None, None, None)[0]')
xWin=$(/usr/bin/dscl localhost read /Search/Users/$USER \
msDS-UserPasswordExpiryTimeComputed 2>/dev/null |\
/usr/bin/awk '/dsAttrTypeNative/{print $NF}')
xUnix=$(echo "($xWin/10000000)-11644473600" | bc)
/bin/date -r $xUnix
@macmule
Copy link

macmule commented Jul 5, 2015

  • Is the output of the script accurate? Yes (well 28 seconds off of ADPassMon 2.10.1).
  • What version of OS X are you running? 10.9.5
  • What version if Windows is/are your DCs running? 2K8

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment