I have to say that i'm quite a newbe to AIX, but i like it very much. @Work i use it and got in a situation where I was wondering which users on a specific system had to change their passwords at next logon. In other words: who has the admchg flag in the /etc/security/passwd file. Especially for the bigger customers with complex password policies on their AIX machine, this can be can be good to know. 
Well... I tried to write a nice script to find out who must change their passwords at next logon:
#! /bin/ksh
# See Accounts which have the ADMCH flags

lsuser -a pgrp groups ALL |awk '{print $1}' >/var/allusers # write usernames in allusers
rm /var/*.usr 2>/dev/null # remove old .usr files

while read myline # read line in var myline
do
pwdadm -q $myline | grep ADMCHG > /var/$myline.usr # read flag ADMCHG from $myline into $myline.usr
ls -la /var/$myline.usr | awk '{print $5}' 2>/dev/null2>/dev/null # read filesize from $myline.usr into $5
done 

while read myline2 # read line in var myline2
do
grep ADMCHG /var/$myline2.usr >/var/temp
if [[ $? == 1 ]]; then
rm /var/$myline2.usr 2>/dev/null
fi
done 

cd /var 2>/dev/null
ls *.usr | sed -e 's/\.[a-zA-Z]*$//' # list *.usr files without .usr extension

Advertisements