UserID password validation using C program


 
Thread Tools Search this Thread
Operating Systems AIX UserID password validation using C program
# 1  
Old 06-12-2006
UserID password validation using C program

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.
# 2  
Old 06-15-2006
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:
Code:
#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
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to read userid and password information from txt file

Hi Experts, I am writing a shell script (for displaying disk space details) which is logging to 15 different servers using following command. ssh userid@servername It is prompting me for password for all 15 servers when I manually run it. However , soon I would like to schedule this script... (4 Replies)
Discussion started by: ajaypatil_am
4 Replies

2. UNIX for Dummies Questions & Answers

userid and pw

questions: a. where can I customized the password of userid in solaris? say I wanted 10digits long, all caps? thanks (4 Replies)
Discussion started by: lhareigh890
4 Replies

3. Shell Programming and Scripting

Read userid and password

Am reading userid and password. code: pmsg "Enter the userid \n" read userid pmsg "Enter password \n" read password pmsg "Enter Database name \n" read database When user type password, it a clear text. I want something like ******** or just a blank any suggestion plz... ... (2 Replies)
Discussion started by: ilugopal
2 Replies

4. UNIX for Dummies Questions & Answers

Shell program with username and password

Hi I am new to unix and I am trying to figure out how to write a shell script with a login name and password. I want to do something along the lines of if both are correct it echoes "you are logged in" and if the password is wrong it echoes "wrong password" and same with the login name. I've tried... (7 Replies)
Discussion started by: thedemonhunter
7 Replies

5. AIX

AIX 5.3 userid password length to 6

Hi All, How can I make the password of only two userid with 6 length while others are using regular policy of 8 or more length. Please help. Thanks. (2 Replies)
Discussion started by: itik
2 Replies

6. Shell Programming and Scripting

Expect program with password as arg

Hi, I have written Expect script that takes root password as argument, and executes another script. The another script prompts for password, which Expect feeds. But Expect shows the password on stdout and in the log. Is there a way to suppress it? (1 Reply)
Discussion started by: illcar
1 Replies

7. UNIX for Advanced & Expert Users

userid

I would like to know the difference between the real user-id and the effective user-id. If user-A runs a program owned by user-B then which is the real user-id and which is the effective user-id ? (1 Reply)
Discussion started by: sundaresh
1 Replies

8. Shell Programming and Scripting

script/program to change the password ?

hi, Somebody have or known where i can find a perl small perl program to change the password. The point: First it verify is the user exist, checking the old typed password and replace it with new. The passwords must be encoded. Thanks, very much! (0 Replies)
Discussion started by: kad
0 Replies

9. Shell Programming and Scripting

String Validation program

Hi I want to validate the sting which one having only A-Z, a-z, *, . ,_ and 0-9 digits. Can anyone send me the program? I tried with following program but its taking all special characters like @ , # % and ^. echo " Enter Text :" read text while ') ] do echo "Character is wrong"... (4 Replies)
Discussion started by: mpk2006
4 Replies

10. Shell Programming and Scripting

ksh program with password

Hi, I am looking for a way to utilize password when the ksh program is launched. What's the standard or best way to do it? Thanks for your help! (5 Replies)
Discussion started by: cin2000
5 Replies
Login or Register to Ask a Question