---
name: "pam_get_user"
section: "3"
platform: "freebsd"
package: "base"
version: "16.0-CURRENT-20261027-61c70dc16a79"
release: "FreeBSD 16.0-CURRENT (2026-10-27)"
platforms: ["linux", "freebsd", "macos"]
url: "https://new.carta.tech/pam_get_user"
---

# pam\_get\_user(3)

retrieve user name

## NAME

**pam\_get\_user** – retrieve user name

## SYNOPSIS

**#include \<sys/types.h\>**

**#include \<security/pam\_appl.h\>**

*int*\

**pam\_get\_user**(*pam\_handle\_t \*pamh*, *const char \*\*user*, *const char \*prompt*);

## DESCRIPTION

The **pam\_get\_user**() function returns the name of the target user, as specified to [pam\_start(3)](/pam_start/3.md). If no user was specified, nor set using [pam\_set\_item(3)](/pam_set_item/3.md), **pam\_get\_user**() will prompt for a user name. Either way, a pointer to the user name is stored in the location pointed to by the *user* argument, and the corresponding PAM item is updated.

The *prompt* argument specifies a prompt to use if no user name is cached. If it is NULL, the PAM\_USER\_PROMPT item will be used. If that item is also NULL, a hardcoded default prompt will be used. Additionally, when **pam\_get\_user**() is called from a service module, the prompt may be affected by module options as described below. The prompt is then expanded using [openpam\_subst(3)](/openpam_subst/3.md) before it is passed to the conversation function.

## MODULE OPTIONS

When called by a service module, **pam\_get\_user**() will recognize the following module options:

- user\_prompt

  Prompt to use when asking for the user name. This option overrides both the *prompt* argument and the PAM\_USER\_PROMPT item.

## RETURN VALUES

The **pam\_get\_user**() function returns one of the following values:

- \[PAM\_SUCCESS\]

  Success.

- \[PAM\_BAD\_ITEM\]

  Unrecognized or restricted item.

- \[PAM\_BUF\_ERR\]

  Memory buffer error.

- \[PAM\_CONV\_ERR\]

  Conversation failure.

- \[PAM\_SYSTEM\_ERR\]

  System error.

## SEE ALSO

[openpam\_get\_option(3)](/openpam_get_option/3.md), [openpam\_subst(3)](/openpam_subst/3.md), [pam(3)](/pam/3.md), [pam\_conv(3)](/pam_conv/3.md), [pam\_get\_authtok(3)](/pam_get_authtok/3.md), [pam\_get\_item(3)](/pam_get_item/3.md), [pam\_set\_item(3)](/pam_set_item/3.md), [pam\_start(3)](/pam_start/3.md), [pam\_strerror(3)](/pam_strerror/3.md)

## STANDARDS

*X/Open Single Sign-On Service (XSSO) - Pluggable Authentication Modules*, June 1997.

## AUTHORS

The **pam\_get\_user**() function and this manual page were developed for the FreeBSD Project by ThinkSec AS and Network Associates Laboratories, the Security Research Division of Network Associates, Inc. under DARPA/SPAWAR contract N66001-01-C-8035 (“CBOSS”), as part of the DARPA CHATS research program.

The OpenPAM library is maintained by Dag-Erling Smørgrav ⟨*des@des.dev*⟩.
