AIX

AIX

Connect with fellow AIX users and experts to gain knowledge, share insights, and solve problems.


#Power
#Power
 View Only
  • 1.  Password expiration.

    Posted Tue July 18, 2006 12:00 PM

    Originally posted by: SystemAdmin


    Can anyone tell me if there is a way to tell when or how long until a user's password is due to expire? I have someone asking me for a list and I can't figure out a way to get the information he wants.
    #AIX-Forum


  • 2.  Re: Password expiration.

    Posted Tue July 18, 2006 01:53 PM

    Originally posted by: SystemAdmin


    I got this from the aix google group a little bit ago. part shell script and part perl script. Both are listed below:

    #!/bin/ksh
    #
    1. expired_pw.sh
    #
    USER=$1
    SERVER=`uname -n`
    #
    1. We need perl for telling us the time in seconds
    #
    if -x /usr/local/bin/perl ; then
    echo
    echo "---- Password expiration information for user ${USER} on ${SERVER}."
    echo
    # get current time
    seconds_since_epoch=`/usr/local/bin/perl -e 'print time;'`
    # get maxage atribute
    maxage=`/usr/sbin/lsuser -a maxage $USER | /usr/bin/awk -F '=' '{print $2 }'`

    #-- remember, maxage in AIX is in weeks
    (( Maxdays = maxage * 7 ))
    if (( maxage > 0 )) ; then
    (( maxage_seconds = maxage * 7 * 24 * 3600 ))
    # Get the time the password was last updated
    lastupdate=`sudo /usr/bin/pwdadm -q $USER | grep lastupdate | awk -F'=' '{pr
    int $2}`
    ###
    # convert the unix date value to readable date format using perl script.
    ###
    updated_last=`last_pw_change_date.prl $lastupdate`
    # Now see what happens
    if (( seconds_since_epoch > lastupdate + maxage_seconds )) ; then
    print "Password has expired. User is required to change it ASAP."
    exit 1
    else
    ((daystoexpire = (lastupdate + maxage_seconds - seconds_since_epoch) / (24
    * 3600 )))
    fi
    fi
    fi
    echo "Password will need to be changed at least ${maxage} weeks \
    (${Maxdays} days)."
    echo "Password was last changed on ${updated_last}"
    echo "Password will expire in ${daystoexpire} days."

    uses this perl script:
    #!/usr/local/bin/perl -w
    #
    1. last_pw_change_date.prl
    #
    1. takes argument in from /etc/security/password and performs
    2. a "print scalar gmtime(arg1)"
    #

    $numargs = @ARGV;
    if ($numargs != 1) {
    print "\nUsage: $0 numeric_rep_of_date\n";
    print "example: $0 1129889197\n\n";
    exit;
    }
    $lastchanged = shift;
    print scalar gmtime($lastchanged), "\n"
    #AIX-Forum