Last active
August 29, 2015 14:24
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
- Is the output of the script accurate?
Yes - What version of OS X are you running?
10.10.4 - What version if Windows is/are your DCs running?
2K12
I used the same method as rderewianko to define USER.
❯ echo $expireDateWin
130849187704716095
❯ echo $expireDateUnix
1440445170
❯ date -r $expireDateUnix
Mon Aug 24 15:39:30 EDT 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
USER=`python -c 'from SystemConfiguration import SCDynamicStoreCopyConsoleUser; import sys; username = (SCDynamicStoreCopyConsoleUser(None, None, None) or [None])[0]; username = [username,""][username in [u"loginwindow", None, u""]]; sys.stdout.write(username + "\n");'`
to get my username. When Run I get:
I get a error of:
(standard_in) 1: parse error
date: option requires an argument -- r
when I echo out both variables, they come back empty.