If you can write a C program, you can call the passwdexpired() system call to get this information. See:
Help -
Here's a code fragment that does the trick. Unfortunately, due to employer restrictions, I can't share the whole code with you. I hacked this out of an existing module, so it is illustrative only.
/* typical includes needed by C programs */
#include <string.h>
#include <ctype.h>
#include <sys/types.h>
#include <time.h>
#include <stdio.h>
#include <errno.h>
#include <stdlib.h>
#include <unistd.h>
#include <time.h>
/* this is the include needed for passwdexpired */
#include <usersec.h>
void main( int argc, char* argv[]) {
char* userid=argv[1];
char p[100] = "";
int rc;
rc = putenv( "LANG=C" ); /* force LANG=C */
/* get password date expiration string */
rc = passwdexpired( userid, &p );
if ( rc == 1 || rc == 2 )
{
printf( "%s\nReset the password \n", p);
exit( 2 );
}
/* some other error */
if ( rc != 0 )
{
if ( errno == ENOENT || errno == ESRCH )
{
fprintf( stderr, "User %s is not defined\n", userid );
}
else
{
fprintf( stderr, "passwdexpired() rc=%d, %s\n", rc, strerror(errno) );
}
exit( 1 );
}
printf( "passwdexpired returned message:\n'%s'\n", p );
}
The binary file must be setuid root, else root must run the program.