---
name: "pam_get_user"
section: "3"
platform: "linux"
package: "pam"
version: "1.7.3-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux", "freebsd", "macos"]
url: "https://new.carta.tech/pam_get_user"
---

# pam\_get\_user(3)

get user name

## NAME

pam\_get\_user - get user name

## SYNOPSIS

```
#include <security/pam_modules.h>
```

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

## DESCRIPTION

The **pam\_get\_user** function returns the name of the user specified by [**pam\_start**(3)](/pam_start/3.md). If no user was specified it returns what **pam\_get\_item (pamh, PAM\_USER, ... );** would have returned. If this is NULL it obtains the username via the [**pam\_conv**(3)](/pam_conv/3.md) mechanism, it prompts the user with the first non-NULL string in the following list:

• The *prompt* argument passed to the function.

• What is returned by pam\_get\_item (pamh, PAM\_USER\_PROMPT, ... );

• The default prompt: "login: "

By whatever means the username is obtained, a pointer to it is returned as the contents of *\*user*. Note, this memory should **not** be *free()*'d or *modified* by the module.

This function sets the *PAM\_USER* item associated with the [**pam\_set\_item**(3)](/pam_set_item/3.md) and [**pam\_get\_item**(3)](/pam_get_item/3.md) functions.

## RETURN VALUES

PAM\_SUCCESS

User name was successfully retrieved.

PAM\_SYSTEM\_ERR

A NULL pointer was submitted.

PAM\_CONV\_ERR

The conversation method supplied by the application failed to obtain the username.

PAM\_BUF\_ERR

Memory buffer error.

PAM\_ABORT

Error resuming an old conversation.

PAM\_CONV\_AGAIN

The conversation method supplied by the application is waiting for an event.

## SEE ALSO

[**pam\_end**(3)](/pam_end/3.md), [**pam\_get\_item**(3)](/pam_get_item/3.md), [**pam\_set\_item**(3)](/pam_set_item/3.md), [**pam\_strerror**(3)](/pam_strerror/3.md)
