---
name: "mbr_uid_to_uuid"
section: "3"
platform: "macos"
package: "Libinfo"
version: "600"
release: "macOS 26.5"
platforms: ["macos"]
url: "https://new.carta.tech/mbr_uid_to_uuid"
---

# mbr\_uid\_to\_uuid(3)

user and group identifier translation functions

## NAME

**mbr\_uid\_to\_uuid,** **mbr\_gid\_to\_uuid,** **mbr\_uuid\_to\_id,** **mbr\_sid\_to\_uuid,** **mbr\_uuid\_to\_sid** – user and group identifier translation functions

## SYNOPSIS

**#include \<membership.h\>**

*int*\

**mbr\_uid\_to\_uuid**(*uid\_t id*, *uuid\_t uu*);

*int*\

**mbr\_gid\_to\_uuid**(*gid\_t id*, *uuid\_t uu*);

*int*\

**mbr\_uuid\_to\_id**(*const uuid\_t uu*, *uid\_t \*id*, *int \*id\_type*);

*int*\

**mbr\_sid\_to\_uuid**(*const nt\_sid\_t \*sid*, *uuid\_t uu*);

*int*\

**mbr\_uuid\_to\_sid**(*const uuid\_t uu*, *nt\_sid\_t \*sid*);

*int*\

**mbr\_sid\_to\_string**(*const nt\_sid\_t \*sid*, *char \*string*);

*int*\

**mbr\_string\_to\_sid**(*const char \*string*, *nt\_sid\_t \*sid*);

## DESCRIPTION

Users and groups can be referred to in multiple ways. In addition to the traditional uid and gid,  every user or group can be referenced by a 128 bit uuid. Additionally, if the user or group is hosted on a PDC or Active Directory server, it will have a 128 bit or larger sid.

These routines communicate with opendirectoryd(8).

**mbr\_uid\_to\_uuid**() takes a uid and looks up the associated user account. It provides the the uuid for that user as an output parameter. Note that this routine will succeed and return a fabricated uuid if the input user uid does not exist. **getpwuid**() should be used to test for the existence of a uid.

**mbr\_gid\_to\_uuid**() similarly gets the uuid associated with a group. Note that this routine will succeed and return a fabricated uuid if the input group gid does not exist. **getgrgid**() should be used to test for the existence of a gid.

**mbr\_uuid\_to\_id**() takes a uuid that refers to a user or group and fetches the corresponding uid or gid. *id\_type* is set to ID\_TYPE\_UID or ID\_TYPE\_GID to indicate which type was found. Note that **mbr\_uuid\_to\_id**() always returns an id even if the uuid is not found. This returned id is not persistent, but can be used to map back to the uuid during runtime. To determine if the uuid exists, the returned id can be used in a call to [getpwuid(3)](/getpwuid/3.md) or [getgrgid(3)](/getgrgid/3.md).

**mbr\_sid\_to\_uuid**() takes a sid and returns the associated uuid.

**mbr\_uuid\_to\_sid**() returns a sid for the associated uuid.

Two additional utility functions are available to convert between sids and a string representation. String representations may be required, for example, when text files or XML files are used to save sid values.

**mbr\_sid\_to\_string**() converts a sid into a string representation. The  *string* parameter must be a buffer of at least 194 characters. The converted string is terminated with a nul character.

**mbr\_string\_to\_sid**() converts an external string representation into a sid.

## RETURN VALUES

These functions return 0 on success or one of the following error codes on failure:

- \[EIO\]

  Communication with opendirectoryd(8) failed.

- \[ENOENT\]

  The mapping can not be performed.

- \[EAUTH\]

  Communication with opendirectoryd(8) failed due to an authentication error.

- \[EINVAL\]

  Invalid arguments were provided.

- \[ENOMEM\]

  Insufficient storage space is available.

**mbr\_gid\_to\_uuid**() and **mbr\_uid\_to\_uuid**() return 0 (success), even if the user/group does not exist.

## SEE ALSO

[getpwuid(3)](/getpwuid/3.md), [getgrgid(3)](/getgrgid/3.md), [mbr\_check\_membership(3)](/mbr_check_membership/3.md), opendirectoryd(8)
