Getting The User's Name To get the name of the user which we sohuld authenticate: extern int pam_get_user(pam_handle_t *pamh, const char **user, const char *prompt); This function will cause the pam library to return the user name, in the following manner: Get the 'PAM_USER' item. If it is defined, return this in '*user'. Otherwise, use the conversation function to prompt the user with the given prompt, and return whatever they typed. Set this new value in the 'PAM_USER' item. Note that the '*user' string should NOT be freed by the module. It will be freed by the PAM library on the next call to pam_get_user, or when the application ends the PAM session.