I am new to AIX. I was wondering if there is a security API on AIX which I can call from my C program to validate the userID and password of a user.
My plan is to have my C program prompt the user for UserID and password. I'll then call the AIX security API to determine what authority the user has (for example which group it belongs to). Base on the authority of the user , my program can determine what the next step should be for the user. I assume that the API will return some error code if the user ID or password is not valid or password has expired.
You don't need an AIX specific API for what you are describing. Any of the examples from Advanced Programming in the UNIX Environment or any other good UNIX programming book should work. For example:
#include <sys/types.h>
#include <pwd.h>
#include <stddef.h>
#include <string.h>
struct passwd *
getpwnam(const char *name)
{
struct passwd *ptr;
setpwent();
while ( (ptr = getpwent()) != NULL) {
if (strcmp(name, ptr->pw_name) == 0)
break; /* found a match */
}
endpwent();
return(ptr); /* ptr is NULL if no match found */
}
Cheers,
Keith