2 Unix SMB/CIFS implementation.
6 Copyright (C) Andrew Tridgell 2003
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>.
25 convert a dom_sid to a string
27 char *dom_sid_string(TALLOC_CTX
*mem_ctx
, const struct dom_sid
*sid
)
34 return talloc_strdup(mem_ctx
, "(NULL SID)");
37 maxlen
= sid
->num_auths
* 11 + 25;
38 ret
= (char *)talloc_size(mem_ctx
, maxlen
);
39 if (!ret
) return talloc_strdup(mem_ctx
, "(SID ERR)");
42 * BIG NOTE: this function only does SIDS where the identauth is not
43 * >= ^32 in a range of 2^48.
46 ia
= (sid
->id_auth
[5]) +
47 (sid
->id_auth
[4] << 8 ) +
48 (sid
->id_auth
[3] << 16) +
49 (sid
->id_auth
[2] << 24);
51 ofs
= snprintf(ret
, maxlen
, "S-%u-%lu",
52 (unsigned int)sid
->sid_rev_num
, (unsigned long)ia
);
54 for (i
= 0; i
< sid
->num_auths
; i
++) {
55 ofs
+= snprintf(ret
+ ofs
, maxlen
- ofs
, "-%lu", (unsigned long)sid
->sub_auths
[i
]);