yuzh is right ... you can add a user by invoking useradd from system() in your program ... there is no separate system call or API (atleast one that I would have heard of )
Main Topics
Browse All TopicsHow do i add a new user programtically (i.e. through a function call) on unix? (and not through a shell command).
I probably just need the function name, no need to post an example unless you have one really handy.
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Sunnycoder is right, there's no API. From man useradd on a Linux box
FILES
/etc/passwd - user account information
/etc/shadow - secure user account information
/etc/group - group information
/etc/default/useradd - default information
/etc/skel - directory containing default files
SEE ALSO
chfn(1), chsh(1), crypt(3), groupadd(8), groupdel(8),
groupmod(8), passwd(1), userdel(8), usermod(8)
As you can see, no APIs referenced other than crypt.
More specifically:
int function(char *username, char *password ) {
char buffer[1024];
// /usr/sbin/useradd may be specific to your system.... use $whereis useradd
snprintf(buffer, 1023, "/usr/sbin/useradd -p %s %s", password, username);
system(buffer);
return 0;
}
(this is what other people have said -- reward them with credit if this helps).
--Nick
Business Accounts
Answer for Membership
by: yuzhPosted on 2003-09-10 at 18:35:35ID: 9333645
You can use system() to call "useradd" to do the job.