]> git.saurik.com Git - apple/libinfo.git/blame - membership.subproj/mbr_uid_to_uuid.3
Libinfo-477.50.4.tar.gz
[apple/libinfo.git] / membership.subproj / mbr_uid_to_uuid.3
CommitLineData
e44d8d47 1.\" Copyright (c) 2005-2010 Apple Inc
b3dd680f
A
2.\" All rights reserved.
3.\"
4.\" Redistribution and use in source and binary forms, with or without
5.\" modification, are permitted provided that the following conditions
6.\" are met:
7.\" 1. Redistributions of source code must retain the above copyright
8.\" notice, this list of conditions and the following disclaimer.
9.\" 2. Redistributions in binary form must reproduce the above copyright
10.\" notice, this list of conditions and the following disclaimer in the
11.\" documentation and/or other materials provided with the distribution.
12.\" 4. Neither the name of Apple Computer nor the names of its contributors
13.\" may be used to endorse or promote products derived from this software
14.\" without specific prior written permission.
15.\"
16.\" THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER AND CONTRIBUTORS ``AS IS'' AND
17.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
20.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26.\" SUCH DAMAGE.
27.\"
28.\"
d31dd049 29.Dd October 10, 2011
b3dd680f
A
30.Dt MBR_UID_TO_UUID 3
31.Os "Mac OS X"
32.Sh NAME
33.Nm mbr_uid_to_uuid,
34.Nm mbr_gid_to_uuid,
35.Nm mbr_uuid_to_id,
36.Nm mbr_sid_to_uuid,
37.Nm mbr_uuid_to_sid
38.Nd user and group identifier translation functions
39.Sh SYNOPSIS
40.In membership.h
41.Ft int
42.Fn mbr_uid_to_uuid "uid_t id" "uuid_t uu"
43.Ft int
44.Fn mbr_gid_to_uuid "gid_t id" "uuid_t uu"
45.Ft int
46.Fn mbr_uuid_to_id "const uuid_t uu" "uid_t *id" "int *id_type"
47.Ft int
48.Fn mbr_sid_to_uuid "const nt_sid_t *sid" "uuid_t uu"
49.Ft int
50.Fn mbr_uuid_to_sid "const uuid_t uu" "nt_sid_t *sid"
e44d8d47
A
51.Ft int
52.Fn mbr_sid_to_string "const nt_sid_t *sid" "char *string"
53.Ft int
54.Fn mbr_string_to_sid "const char *string" "nt_sid_t *sid"
b3dd680f
A
55.Sh DESCRIPTION
56Users and groups can be referred to in multiple ways.
57In addition to the traditional uid and gid,
58every user or group can be referenced by a 128 bit uuid.
59Additionally, if the user or group is hosted on a PDC
60or Active Directory server, it will have a 128 bit or larger sid.
61.Pp
d31dd049
A
62These routines communicate with
63.Xr openditectoryd 8 .
b3dd680f
A
64.Pp
65.Fn mbr_uid_to_uuid
66takes a uid and looks up the associated user account.
67It provides the the uuid for that user as an output parameter.
d49d4c81
A
68Note that this routine will succeed and return a fabricated uuid if the input user uid does not exist.
69.Fn getpwuid
70should be used to test for the existence of a uid.
b3dd680f
A
71.Pp
72.Fn mbr_gid_to_uuid
73similarly gets the uuid associated with a group.
d49d4c81
A
74Note that this routine will succeed and return a fabricated uuid if the input group gid does not exist.
75.Fn getgrgid
76should be used to test for the existence of a gid.
b3dd680f
A
77.Pp
78.Fn mbr_uuid_to_id
79takes a uuid that refers to a user or group and fetches the corresponding uid or gid.
80.Fa id_type
81is set to ID_TYPE_UID or ID_TYPE_GID to indicate which type was found.
82Note that
83.Fn mbr_uuid_to_id
84always returns an id even if the uuid is not found.
85This returned id is not persistant,
86but can be used to map back to the uuid during runtime.
87To determine if the uuid exists, the returned id can be used in a call to
88.Xr getpwuid 3
89or
90.Xr getgrgid 3 .
91.Pp
92.Fn mbr_sid_to_uuid
93takes a sid and returns the associated uuid.
b3dd680f
A
94.Pp
95.Fn mbr_uuid_to_sid
96returns a sid for the associated uuid.
e44d8d47
A
97.Pp
98Two additional utility functions are available to convert between sids and a string representation.
99String representations may be required, for example, when text files or XML files are used to save sid values.
100.Pp
101.Fn mbr_sid_to_string
102converts a sid into a string representation.
103The
104.Fa string
105parameter must be a buffer of at least 194 characters.
106The converted string is terminated with a nul character.
107.Pp
108.Fn mbr_string_to_sid
109converts an external string representation into a sid.
b3dd680f 110.Sh RETURN VALUES
d31dd049
A
111These functions return 0 on success or one of the following error codes on failure:
112.Bl -tag -width Er
113.It Bq Er EIO
114Communication with
115.Xr openditectoryd 8
116failed.
117.It Bq Er ENOENT
118The mapping can not be performed.
119.It Bq Er EAUTH
120Communication with
121.Xr openditectoryd 8
122failed due to an authentication error.
123.It Bq Er EINVAL
124Invalid arguments were provided.
125.It Bq Er ENOMEM
126Insufficient storage space is available.
127.El
d49d4c81
A
128.Pp
129.Fn mbr_gid_to_uuid
130and
131.Fn mbr_uid_to_uuid
132return 0 (success), even if the user/group does not exist.
b3dd680f
A
133.Sh SEE ALSO
134.Xr getpwuid 3 ,
135.Xr getgrgid 3 ,
136.Xr mbr_check_membership 3 ,
d31dd049 137.Xr openditectoryd 8