[Fed-Talk] Passwords & local accounts: Number of days remaining
[Fed-Talk] Passwords & local accounts: Number of days remaining
- Subject: [Fed-Talk] Passwords & local accounts: Number of days remaining
- From: Michael Kluskens <email@hidden>
- Date: Thu, 13 Dec 2012 12:14:30 -0500
If anyone is interested, I found the easiest way to determine the number of days remaining before a local account password expires was to use a shell script, the basic outline is as follows:
#!/bin/sh
# Number of days before a password expires
pwPolicy=90
user=`whoami`
# date of last password change
lastpwdOD=`dscl . -readpl /Users/$user PasswordPolicyOptions passwordTimestamp | sed 's/passwordTimestamp: //' | awk '{split($0,a," ");print a[1]}'`
# date in Unix seconds
lastdate=`date -j -f "%Y-%m-%d" $lastpwdOD "+%s"`
#get todays date in Unix seconds
todayUnix=`date "+%s"`
#get the difference in seconds
diffUnix=`expr $todayUnix - $lastdate`
# convert to days
daysago=`expr $diffUnix / 86400`
# number of days remaining
daysremaining=`expr $pwPolicy - $daysago`
echo $daysremaining
This is loosely based on a script for Active Directory password expiration warnings.
Turning this into an Applescript with additional logic would be the next step.
Michael
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Fed-talk mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden