How to programmatically reset a users password.?

Hello all,
I have a small C++ app for my solaris admins. I need to set it up so they can reset a users password. The admin does not have the old password. How can I reset a users password to a temp password either using passwd or PAM? I need to do this from within my C++ app. I have searched the web over and cannot find how to do this.

Thank you.

Are going to do a system call inside your C++ program? You can simply use the -f flag to force the uset to change their password after you set it to a temporary one. man passwd

Rich Teer has pty.c and some related code on hist website. It is essentially a shell script driven expect-like bit of code that creates a "headless" pty.

Go here: http://www.rite-group.com/rich/ssp/

Then download the source code.

A simple

sudo passwd $user

..... and you are not prompted for the old password. You will be prompted twice for the new password, so verification is taken care of too. Additionally, sudo will write to the syslog for your auditors to drool over.

I hope that this helps,
Robin
Liverpool/Blackburn
UK