---
name: "nfs4_uid_to_name"
section: "3"
platform: "linux"
package: "nfsidmap"
version: "3.1.1-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/nfs4_uid_to_name"
---

# nfs4\_uid\_to\_name(3)

ID mapping routines used for NFSv4

## NAME

nfs4\_uid\_to\_name, nfs4\_gid\_to\_name, nfs4\_name\_to\_uid, nfs4\_name\_to\_gid, nfs4\_init\_name\_mapping, nfs4\_get\_default\_domain, nfs4\_gss\_princ\_to\_ids, nfs4\_gss\_princ\_to\_grouplist, nfs4\_gss\_princ\_to\_ids\_ex, nfs4\_gss\_princ\_to\_grouplist\_ex, nfs4\_set\_debug - ID mapping routines used for NFSv4

## SYNOPSIS

**#include \<nfs4\_idmap.h\>**

**int nfs4\_init\_name\_mapping(char \*conffile);**

**int nfs4\_get\_default\_domain(char \*server, char \*domain, size\_t len);**

**int nfs4\_uid\_to\_name(uid\_t uid, char \*domain, char \*name, size\_t len);**

**int nfs4\_uid\_to\_owner(uid\_t uid, char \*domain, char \*name, size\_t len);**

**int nfs4\_gid\_to\_name(gid\_t gid, char \*domain, char \*name, size\_t len);**

**int nfs4\_gid\_to\_owner(gid\_t gid, char \*domain, char \*name, size\_t len);**

**int nfs4\_name\_to\_uid(char \*name, uid\_t \*uid);**

**int nfs4\_name\_to\_gid(char \*name, gid\_t \*gid);**

**int nfs4\_owner\_to\_uid(char \*name, uid\_t \*uid);**

**int nfs4\_owner\_to\_gid(char \*name, gid\_t \*gid);**

**int nfs4\_gss\_princ\_to\_ids(char \*secname, char \*princ, uid\_t \*uid, gid\_t \*gid);**

**int nfs4\_gss\_princ\_to\_grouplist(char \*secname, char \*princ, gid\_t \*groups, int \*ngroups);**

**int nfs4\_gss\_princ\_to\_ids\_ex(char \*secname, char \*princ, uid\_t \*uid, gid\_t \*gid, extra\_mapping\_params \*\*ex);**

**int nfs4\_gss\_princ\_to\_grouplist\_ex(char \*secname, char \*princ, gid\_t \*groups, int \*ngroups, extra\_mapping\_params \*\*ex);**

**void nfs4\_set\_debug(int dbg\_level, void (\*logger)(const char \*, ...));**

## DESCRIPTION

NFSv4 uses names of the form *user@domain*. To write code that helps the kernel map uid's (as rpc.idmapd does) or that processes NFSv4 ACLs, you need to be able to convert between NFSv4 names and local uids and gids.

The **nfs4\_uid\_to\_name()** and **nfs4\_gid\_to\_name()** functions, given *uid* or *gid* and  *domain* (as a null-terminated string), write the corresponding nfsv4 name into the buffer provided in *name*, which must be of length at least *len*.

The **nfs4\_uid\_to\_owner()** and **nfs4\_gid\_to\_group\_owner()** functions, given *uid* or *gid* and *domain* (as a null-terminated string), write the corresponding nfsv4 name into the buffer provided in *name*, which must be of length at least *len*. If there is no valid mapping from *uid* or *gid* to *name*, then the numerical string representing uid or gid is returned instead.

The  **nfs4\_name\_to\_uid()** and **nfs4\_name\_to\_gid()** functions, given *name* (as a null-terminated string), return the corresponding uid or gid in the second parameter.

The  **nfs4\_owner\_to\_uid()** and **nfs4\_group\_owner\_to\_gid()** functions, given *name* (as a null-terminated string), return the corresponding uid or gid in the second parameter. If there is no valid mapping from *name* to *uid* or *gid* the value for the user or group "nobody" will be returned instead.

The **nfs4\_init\_name\_mapping()** function must be called before using any of these functions.  It reads defaults from the configuration file at the provided path, usually "etc/idmapd.conf".

The *domain* argument to the id-to-name functions is there to provide a hint to the name mapper in the case where an id might be mapped to names in multiple domains. In most cases, this argument should just be the name returned in the *domain* argument to **nfs4\_get\_default\_domain()** which should be called with *server* set to NULL.  The *domain* should be a buffer of length *len*. The constant NFS4\_MAX\_DOMAIN\_LEN may be used to determine a reasonable value for that length.

The function **nfs4\_get\_grouplist()**, given a *name*, fills the provided array *groups* with up to  *\*ngroups* group IDs corresponding to which the user *name* belongs to, setting *\*ngroups* to the actual number of such groups.  If the user belongs to more than *\*ngroups* groups, then an error is returned and the actual number of groups is stored in \*ngroups.

Functions **nfs4\_gss\_princ\_to\_ids()**, **nfs4\_gss\_princ\_to\_grouplist()**, **nfs4\_gss\_princ\_to\_ids\_ex()**, and **nfs4\_gss\_princ\_to\_grouplist\_ex()** are used to convert from a gss principal name (as returned by **gss\_display\_name()**) to a uid and gid, or list of gids.

Finally, **nfs4\_set\_debug()** allows the application to set a debugging level to produce extra debugging information from within the library.  The optional *logger* function specifies an alternative logging function to call for the debug messages rather than the default internal function within the library.

## RETURN VALUE

All functions return 0 or, in the case of error, -ERRNO.
