• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
[Fed-Talk] Passwords & local accounts: Number of days remaining
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[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

  • Prev by Date: Re: [Fed-Talk] I AM THE STIG
  • Next by Date: [Fed-Talk] Applescript for local password expiration
  • Previous by thread: [Fed-Talk] Password expiration warning
  • Next by thread: [Fed-Talk] Applescript for local password expiration
  • Index(es):
    • Date
    • Thread