2 Unix SMB/CIFS implementation.
6 Copyright (C) Gerald (Jerry) Carter 2007
7 Copyright (C) Volker Lendecke 2010
10 This library is free software; you can redistribute it and/or
11 modify it under the terms of the GNU Lesser General Public
12 License as published by the Free Software Foundation; either
13 version 3 of the License, or (at your option) any later version.
15 This library is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 Library General Public License for more details.
20 You should have received a copy of the GNU Lesser General Public License
21 along with this program. If not, see <http://www.gnu.org/licenses/>.
24 /* Required Headers */
27 #include "libwbclient.h"
28 #include "../winbind_client.h"
30 /* Convert a sid to a string into a buffer. Return the string
31 * length. If buflen is too small, return the string length that would
32 * result if it was long enough. */
33 int wbcSidToStringBuf(const struct wbcDomainSid
*sid
, char *buf
, int buflen
)
39 strlcpy(buf
, "(NULL SID)", buflen
);
40 return 10; /* strlen("(NULL SID)") */
44 * BIG NOTE: this function only does SIDS where the identauth is not
45 * >= ^32 in a range of 2^48.
48 id_auth
= sid
->id_auth
[5] +
49 (sid
->id_auth
[4] << 8) +
50 (sid
->id_auth
[3] << 16) +
51 (sid
->id_auth
[2] << 24);
53 ofs
= snprintf(buf
, buflen
, "S-%u-%lu",
54 (unsigned int)sid
->sid_rev_num
, (unsigned long)id_auth
);
56 for (i
= 0; i
< sid
->num_auths
; i
++) {
57 ofs
+= snprintf(buf
+ ofs
, MAX(buflen
- ofs
, 0), "-%lu",
58 (unsigned long)sid
->sub_auths
[i
]);
63 /* Convert a binary SID to a character string */
64 wbcErr
wbcSidToString(const struct wbcDomainSid
*sid
,
67 char buf
[WBC_SID_STRING_BUFLEN
];
72 return WBC_ERR_INVALID_SID
;
75 len
= wbcSidToStringBuf(sid
, buf
, sizeof(buf
));
77 if (len
+1 > sizeof(buf
)) {
78 return WBC_ERR_INVALID_SID
;
81 result
= (char *)wbcAllocateMemory(len
+1, 1, NULL
);
83 return WBC_ERR_NO_MEMORY
;
85 memcpy(result
, buf
, len
+1);
88 return WBC_ERR_SUCCESS
;
91 /* Convert a character string to a binary SID */
92 wbcErr
wbcStringToSid(const char *str
,
93 struct wbcDomainSid
*sid
)
98 wbcErr wbc_status
= WBC_ERR_UNKNOWN_FAILURE
;
101 wbc_status
= WBC_ERR_INVALID_PARAM
;
102 BAIL_ON_WBC_ERROR(wbc_status
);
105 /* Sanity check for either "S-" or "s-" */
108 || (str
[0]!='S' && str
[0]!='s')
111 wbc_status
= WBC_ERR_INVALID_PARAM
;
112 BAIL_ON_WBC_ERROR(wbc_status
);
115 /* Get the SID revision number */
118 x
= (uint32_t)strtol(p
, &q
, 10);
119 if (x
==0 || !q
|| *q
!='-') {
120 wbc_status
= WBC_ERR_INVALID_SID
;
121 BAIL_ON_WBC_ERROR(wbc_status
);
123 sid
->sid_rev_num
= (uint8_t)x
;
125 /* Next the Identifier Authority. This is stored in big-endian
126 in a 6 byte array. */
129 x
= (uint32_t)strtol(p
, &q
, 10);
131 wbc_status
= WBC_ERR_INVALID_SID
;
132 BAIL_ON_WBC_ERROR(wbc_status
);
134 sid
->id_auth
[5] = (x
& 0x000000ff);
135 sid
->id_auth
[4] = (x
& 0x0000ff00) >> 8;
136 sid
->id_auth
[3] = (x
& 0x00ff0000) >> 16;
137 sid
->id_auth
[2] = (x
& 0xff000000) >> 24;
141 /* now read the the subauthorities */
145 while (sid
->num_auths
< WBC_MAXSUBAUTHS
) {
146 x
=(uint32_t)strtoul(p
, &q
, 10);
150 wbc_status
= WBC_ERR_INVALID_SID
;
151 BAIL_ON_WBC_ERROR(wbc_status
);
153 sid
->sub_auths
[sid
->num_auths
++] = x
;
161 /* IF we ended early, then the SID could not be converted */
164 wbc_status
= WBC_ERR_INVALID_SID
;
165 BAIL_ON_WBC_ERROR(wbc_status
);
168 wbc_status
= WBC_ERR_SUCCESS
;
176 /* Convert a domain and name to SID */
177 wbcErr
wbcLookupName(const char *domain
,
179 struct wbcDomainSid
*sid
,
180 enum wbcSidType
*name_type
)
182 struct winbindd_request request
;
183 struct winbindd_response response
;
184 wbcErr wbc_status
= WBC_ERR_UNKNOWN_FAILURE
;
186 if (!sid
|| !name_type
) {
187 wbc_status
= WBC_ERR_INVALID_PARAM
;
188 BAIL_ON_WBC_ERROR(wbc_status
);
191 /* Initialize request */
193 ZERO_STRUCT(request
);
194 ZERO_STRUCT(response
);
196 /* dst is already null terminated from the memset above */
198 strncpy(request
.data
.name
.dom_name
, domain
,
199 sizeof(request
.data
.name
.dom_name
)-1);
200 strncpy(request
.data
.name
.name
, name
,
201 sizeof(request
.data
.name
.name
)-1);
203 wbc_status
= wbcRequestResponse(WINBINDD_LOOKUPNAME
,
206 BAIL_ON_WBC_ERROR(wbc_status
);
208 wbc_status
= wbcStringToSid(response
.data
.sid
.sid
, sid
);
209 BAIL_ON_WBC_ERROR(wbc_status
);
211 *name_type
= (enum wbcSidType
)response
.data
.sid
.type
;
213 wbc_status
= WBC_ERR_SUCCESS
;
220 /* Convert a SID to a domain and name */
221 wbcErr
wbcLookupSid(const struct wbcDomainSid
*sid
,
224 enum wbcSidType
*pname_type
)
226 struct winbindd_request request
;
227 struct winbindd_response response
;
228 wbcErr wbc_status
= WBC_ERR_UNKNOWN_FAILURE
;
232 return WBC_ERR_INVALID_PARAM
;
235 /* Initialize request */
237 ZERO_STRUCT(request
);
238 ZERO_STRUCT(response
);
240 wbcSidToStringBuf(sid
, request
.data
.sid
, sizeof(request
.data
.sid
));
244 wbc_status
= wbcRequestResponse(WINBINDD_LOOKUPSID
, &request
,
246 if (!WBC_ERROR_IS_OK(wbc_status
)) {
250 /* Copy out result */
252 wbc_status
= WBC_ERR_NO_MEMORY
;
256 domain
= wbcStrDup(response
.data
.name
.dom_name
);
257 if (domain
== NULL
) {
260 name
= wbcStrDup(response
.data
.name
.name
);
264 if (pdomain
!= NULL
) {
272 if (pname_type
!= NULL
) {
273 *pname_type
= (enum wbcSidType
)response
.data
.name
.type
;
275 wbc_status
= WBC_ERR_SUCCESS
;
278 wbcFreeMemory(domain
);
282 static void wbcDomainInfosDestructor(void *ptr
)
284 struct wbcDomainInfo
*i
= (struct wbcDomainInfo
*)ptr
;
286 while (i
->short_name
!= NULL
) {
287 wbcFreeMemory(i
->short_name
);
288 wbcFreeMemory(i
->dns_name
);
293 static void wbcTranslatedNamesDestructor(void *ptr
)
295 struct wbcTranslatedName
*n
= (struct wbcTranslatedName
*)ptr
;
297 while (n
->name
!= NULL
) {
298 wbcFreeMemory(n
->name
);
303 wbcErr
wbcLookupSids(const struct wbcDomainSid
*sids
, int num_sids
,
304 struct wbcDomainInfo
**pdomains
, int *pnum_domains
,
305 struct wbcTranslatedName
**pnames
)
307 struct winbindd_request request
;
308 struct winbindd_response response
;
309 wbcErr wbc_status
= WBC_ERR_UNKNOWN_FAILURE
;
310 int buflen
, i
, extra_len
, num_domains
, num_names
;
311 char *sidlist
, *p
, *q
, *extra_data
;
312 struct wbcDomainInfo
*domains
= NULL
;
313 struct wbcTranslatedName
*names
= NULL
;
315 buflen
= num_sids
* (WBC_SID_STRING_BUFLEN
+ 1) + 1;
317 sidlist
= (char *)malloc(buflen
);
318 if (sidlist
== NULL
) {
319 return WBC_ERR_NO_MEMORY
;
324 for (i
=0; i
<num_sids
; i
++) {
328 remaining
= buflen
- (p
- sidlist
);
330 len
= wbcSidToStringBuf(&sids
[i
], p
, remaining
);
331 if (len
> remaining
) {
333 return WBC_ERR_UNKNOWN_FAILURE
;
341 ZERO_STRUCT(request
);
342 ZERO_STRUCT(response
);
344 request
.extra_data
.data
= sidlist
;
345 request
.extra_len
= p
- sidlist
;
347 wbc_status
= wbcRequestResponse(WINBINDD_LOOKUPSIDS
,
348 &request
, &response
);
350 if (!WBC_ERROR_IS_OK(wbc_status
)) {
354 extra_len
= response
.length
- sizeof(struct winbindd_response
);
355 extra_data
= (char *)response
.extra_data
.data
;
357 if ((extra_len
<= 0) || (extra_data
[extra_len
-1] != '\0')) {
358 goto wbc_err_invalid
;
363 num_domains
= strtoul(p
, &q
, 10);
365 goto wbc_err_invalid
;
369 domains
= (struct wbcDomainInfo
*)wbcAllocateMemory(
370 num_domains
+1, sizeof(struct wbcDomainInfo
),
371 wbcDomainInfosDestructor
);
372 if (domains
== NULL
) {
373 wbc_status
= WBC_ERR_NO_MEMORY
;
377 for (i
=0; i
<num_domains
; i
++) {
381 goto wbc_err_invalid
;
384 wbc_status
= wbcStringToSid(p
, &domains
[i
].sid
);
385 if (!WBC_ERROR_IS_OK(wbc_status
)) {
392 goto wbc_err_invalid
;
395 domains
[i
].short_name
= wbcStrDup(p
);
396 if (domains
[i
].short_name
== NULL
) {
397 wbc_status
= WBC_ERR_NO_MEMORY
;
403 num_names
= strtoul(p
, &q
, 10);
405 goto wbc_err_invalid
;
409 if (num_names
!= num_sids
) {
410 goto wbc_err_invalid
;
413 names
= (struct wbcTranslatedName
*)wbcAllocateMemory(
414 num_names
+1, sizeof(struct wbcTranslatedName
),
415 wbcTranslatedNamesDestructor
);
417 wbc_status
= WBC_ERR_NO_MEMORY
;
421 for (i
=0; i
<num_names
; i
++) {
423 names
[i
].domain_index
= strtoul(p
, &q
, 10);
424 if (names
[i
].domain_index
< 0) {
425 goto wbc_err_invalid
;
427 if (names
[i
].domain_index
>= num_domains
) {
428 goto wbc_err_invalid
;
432 goto wbc_err_invalid
;
436 names
[i
].type
= strtoul(p
, &q
, 10);
438 goto wbc_err_invalid
;
444 goto wbc_err_invalid
;
447 names
[i
].name
= wbcStrDup(p
);
448 if (names
[i
].name
== NULL
) {
449 wbc_status
= WBC_ERR_NO_MEMORY
;
455 goto wbc_err_invalid
;
460 winbindd_free_response(&response
);
461 return WBC_ERR_SUCCESS
;
464 wbc_status
= WBC_ERR_INVALID_RESPONSE
;
466 winbindd_free_response(&response
);
467 wbcFreeMemory(domains
);
468 wbcFreeMemory(names
);
472 /* Translate a collection of RIDs within a domain to names */
474 wbcErr
wbcLookupRids(struct wbcDomainSid
*dom_sid
,
477 const char **pp_domain_name
,
478 const char ***pnames
,
479 enum wbcSidType
**ptypes
)
481 size_t i
, len
, ridbuf_size
;
484 struct winbindd_request request
;
485 struct winbindd_response response
;
486 char *domain_name
= NULL
;
487 const char **names
= NULL
;
488 enum wbcSidType
*types
= NULL
;
489 wbcErr wbc_status
= WBC_ERR_UNKNOWN_FAILURE
;
491 /* Initialise request */
493 ZERO_STRUCT(request
);
494 ZERO_STRUCT(response
);
496 if (!dom_sid
|| (num_rids
== 0)) {
497 wbc_status
= WBC_ERR_INVALID_PARAM
;
498 BAIL_ON_WBC_ERROR(wbc_status
);
501 wbcSidToStringBuf(dom_sid
, request
.data
.sid
, sizeof(request
.data
.sid
));
503 /* Even if all the Rids were of maximum 32bit values,
504 we would only have 11 bytes per rid in the final array
505 ("4294967296" + \n). Add one more byte for the
508 ridbuf_size
= (sizeof(char)*11) * num_rids
+ 1;
510 ridlist
= (char *)malloc(ridbuf_size
);
511 BAIL_ON_PTR_ERROR(ridlist
, wbc_status
);
514 for (i
=0; i
<num_rids
; i
++) {
515 len
+= snprintf(ridlist
+ len
, ridbuf_size
- len
, "%u\n",
521 request
.extra_data
.data
= ridlist
;
522 request
.extra_len
= len
;
524 wbc_status
= wbcRequestResponse(WINBINDD_LOOKUPRIDS
,
528 BAIL_ON_WBC_ERROR(wbc_status
);
530 domain_name
= wbcStrDup(response
.data
.domain_name
);
531 BAIL_ON_PTR_ERROR(domain_name
, wbc_status
);
533 names
= wbcAllocateStringArray(num_rids
);
534 BAIL_ON_PTR_ERROR(names
, wbc_status
);
536 types
= (enum wbcSidType
*)wbcAllocateMemory(
537 num_rids
, sizeof(enum wbcSidType
), NULL
);
538 BAIL_ON_PTR_ERROR(types
, wbc_status
);
540 p
= (char *)response
.extra_data
.data
;
542 for (i
=0; i
<num_rids
; i
++) {
546 wbc_status
= WBC_ERR_INVALID_RESPONSE
;
550 types
[i
] = (enum wbcSidType
)strtoul(p
, &q
, 10);
553 wbc_status
= WBC_ERR_INVALID_RESPONSE
;
559 if ((q
= strchr(p
, '\n')) == NULL
) {
560 wbc_status
= WBC_ERR_INVALID_RESPONSE
;
566 names
[i
] = strdup(p
);
567 BAIL_ON_PTR_ERROR(names
[i
], wbc_status
);
573 wbc_status
= WBC_ERR_INVALID_RESPONSE
;
577 wbc_status
= WBC_ERR_SUCCESS
;
580 winbindd_free_response(&response
);
582 if (WBC_ERROR_IS_OK(wbc_status
)) {
583 *pp_domain_name
= domain_name
;
588 wbcFreeMemory(domain_name
);
589 wbcFreeMemory(names
);
590 wbcFreeMemory(types
);
596 /* Get the groups a user belongs to */
597 wbcErr
wbcLookupUserSids(const struct wbcDomainSid
*user_sid
,
598 bool domain_groups_only
,
600 struct wbcDomainSid
**_sids
)
604 struct winbindd_request request
;
605 struct winbindd_response response
;
606 struct wbcDomainSid
*sids
= NULL
;
607 wbcErr wbc_status
= WBC_ERR_UNKNOWN_FAILURE
;
610 /* Initialise request */
612 ZERO_STRUCT(request
);
613 ZERO_STRUCT(response
);
616 wbc_status
= WBC_ERR_INVALID_PARAM
;
617 BAIL_ON_WBC_ERROR(wbc_status
);
620 wbcSidToStringBuf(user_sid
, request
.data
.sid
, sizeof(request
.data
.sid
));
622 if (domain_groups_only
) {
623 cmd
= WINBINDD_GETUSERDOMGROUPS
;
625 cmd
= WINBINDD_GETUSERSIDS
;
628 wbc_status
= wbcRequestResponse(cmd
,
631 BAIL_ON_WBC_ERROR(wbc_status
);
633 if (response
.data
.num_entries
&&
634 !response
.extra_data
.data
) {
635 wbc_status
= WBC_ERR_INVALID_RESPONSE
;
636 BAIL_ON_WBC_ERROR(wbc_status
);
639 sids
= (struct wbcDomainSid
*)wbcAllocateMemory(
640 response
.data
.num_entries
, sizeof(struct wbcDomainSid
),
642 BAIL_ON_PTR_ERROR(sids
, wbc_status
);
644 s
= (const char *)response
.extra_data
.data
;
645 for (i
= 0; i
< response
.data
.num_entries
; i
++) {
646 char *n
= strchr(s
, '\n');
650 wbc_status
= wbcStringToSid(s
, &sids
[i
]);
651 BAIL_ON_WBC_ERROR(wbc_status
);
655 *num_sids
= response
.data
.num_entries
;
658 wbc_status
= WBC_ERR_SUCCESS
;
661 winbindd_free_response(&response
);
670 wbcErr
_sid_to_rid(struct wbcDomainSid
*sid
, uint32_t *rid
)
672 if (sid
->num_auths
< 1) {
673 return WBC_ERR_INVALID_RESPONSE
;
675 *rid
= sid
->sub_auths
[sid
->num_auths
- 1];
677 return WBC_ERR_SUCCESS
;
680 /* Get alias membership for sids */
681 wbcErr
wbcGetSidAliases(const struct wbcDomainSid
*dom_sid
,
682 struct wbcDomainSid
*sids
,
684 uint32_t **alias_rids
,
685 uint32_t *num_alias_rids
)
689 struct winbindd_request request
;
690 struct winbindd_response response
;
691 ssize_t extra_data_len
= 0;
692 char * extra_data
= NULL
;
694 struct wbcDomainSid sid
;
695 wbcErr wbc_status
= WBC_ERR_UNKNOWN_FAILURE
;
696 uint32_t * rids
= NULL
;
698 /* Initialise request */
700 ZERO_STRUCT(request
);
701 ZERO_STRUCT(response
);
704 wbc_status
= WBC_ERR_INVALID_PARAM
;
708 wbcSidToStringBuf(dom_sid
, request
.data
.sid
, sizeof(request
.data
.sid
));
710 /* Lets assume each sid is around 57 characters
711 * S-1-5-21-AAAAAAAAAAA-BBBBBBBBBBB-CCCCCCCCCCC-DDDDDDDDDDD\n */
712 buflen
= 57 * num_sids
;
713 extra_data
= (char *)malloc(buflen
);
715 wbc_status
= WBC_ERR_NO_MEMORY
;
719 /* Build the sid list */
720 for (i
=0; i
<num_sids
; i
++) {
721 char sid_str
[WBC_SID_STRING_BUFLEN
];
724 sid_len
= wbcSidToStringBuf(&sids
[i
], sid_str
, sizeof(sid_str
));
726 if (buflen
< extra_data_len
+ sid_len
+ 2) {
728 extra_data
= (char *)realloc(extra_data
, buflen
);
730 wbc_status
= WBC_ERR_NO_MEMORY
;
731 BAIL_ON_WBC_ERROR(wbc_status
);
735 strncpy(&extra_data
[extra_data_len
], sid_str
,
736 buflen
- extra_data_len
);
737 extra_data_len
+= sid_len
;
738 extra_data
[extra_data_len
++] = '\n';
739 extra_data
[extra_data_len
] = '\0';
743 request
.extra_data
.data
= extra_data
;
744 request
.extra_len
= extra_data_len
;
746 wbc_status
= wbcRequestResponse(WINBINDD_GETSIDALIASES
,
749 BAIL_ON_WBC_ERROR(wbc_status
);
751 if (response
.data
.num_entries
&&
752 !response
.extra_data
.data
) {
753 wbc_status
= WBC_ERR_INVALID_RESPONSE
;
757 rids
= (uint32_t *)wbcAllocateMemory(response
.data
.num_entries
,
758 sizeof(uint32_t), NULL
);
759 BAIL_ON_PTR_ERROR(sids
, wbc_status
);
761 s
= (const char *)response
.extra_data
.data
;
762 for (i
= 0; i
< response
.data
.num_entries
; i
++) {
763 char *n
= strchr(s
, '\n');
767 wbc_status
= wbcStringToSid(s
, &sid
);
768 BAIL_ON_WBC_ERROR(wbc_status
);
769 wbc_status
= _sid_to_rid(&sid
, &rids
[i
]);
770 BAIL_ON_WBC_ERROR(wbc_status
);
774 *num_alias_rids
= response
.data
.num_entries
;
777 wbc_status
= WBC_ERR_SUCCESS
;
781 winbindd_free_response(&response
);
788 wbcErr
wbcListUsers(const char *domain_name
,
789 uint32_t *_num_users
,
790 const char ***_users
)
792 wbcErr wbc_status
= WBC_ERR_UNKNOWN_FAILURE
;
793 struct winbindd_request request
;
794 struct winbindd_response response
;
795 uint32_t num_users
= 0;
796 const char **users
= NULL
;
799 /* Initialise request */
801 ZERO_STRUCT(request
);
802 ZERO_STRUCT(response
);
805 strncpy(request
.domain_name
, domain_name
,
806 sizeof(request
.domain_name
)-1);
809 wbc_status
= wbcRequestResponse(WINBINDD_LIST_USERS
,
812 BAIL_ON_WBC_ERROR(wbc_status
);
814 users
= wbcAllocateStringArray(response
.data
.num_entries
);
816 return WBC_ERR_NO_MEMORY
;
819 /* Look through extra data */
821 next
= (const char *)response
.extra_data
.data
;
826 if (num_users
>= response
.data
.num_entries
) {
827 wbc_status
= WBC_ERR_INVALID_RESPONSE
;
832 k
= strchr(next
, ',');
841 users
[num_users
] = strdup(current
);
842 BAIL_ON_PTR_ERROR(users
[num_users
], wbc_status
);
845 if (num_users
!= response
.data
.num_entries
) {
846 wbc_status
= WBC_ERR_INVALID_RESPONSE
;
850 *_num_users
= response
.data
.num_entries
;
853 wbc_status
= WBC_ERR_SUCCESS
;
856 winbindd_free_response(&response
);
857 wbcFreeMemory(users
);
862 wbcErr
wbcListGroups(const char *domain_name
,
863 uint32_t *_num_groups
,
864 const char ***_groups
)
866 wbcErr wbc_status
= WBC_ERR_UNKNOWN_FAILURE
;
867 struct winbindd_request request
;
868 struct winbindd_response response
;
869 uint32_t num_groups
= 0;
870 const char **groups
= NULL
;
873 /* Initialise request */
875 ZERO_STRUCT(request
);
876 ZERO_STRUCT(response
);
879 strncpy(request
.domain_name
, domain_name
,
880 sizeof(request
.domain_name
)-1);
883 wbc_status
= wbcRequestResponse(WINBINDD_LIST_GROUPS
,
886 BAIL_ON_WBC_ERROR(wbc_status
);
888 groups
= wbcAllocateStringArray(response
.data
.num_entries
);
889 if (groups
== NULL
) {
890 return WBC_ERR_NO_MEMORY
;
893 /* Look through extra data */
895 next
= (const char *)response
.extra_data
.data
;
900 if (num_groups
>= response
.data
.num_entries
) {
901 wbc_status
= WBC_ERR_INVALID_RESPONSE
;
906 k
= strchr(next
, ',');
915 groups
[num_groups
] = strdup(current
);
916 BAIL_ON_PTR_ERROR(groups
[num_groups
], wbc_status
);
919 if (num_groups
!= response
.data
.num_entries
) {
920 wbc_status
= WBC_ERR_INVALID_RESPONSE
;
924 *_num_groups
= response
.data
.num_entries
;
927 wbc_status
= WBC_ERR_SUCCESS
;
930 winbindd_free_response(&response
);
931 wbcFreeMemory(groups
);
935 wbcErr
wbcGetDisplayName(const struct wbcDomainSid
*sid
,
938 enum wbcSidType
*pname_type
)
943 enum wbcSidType name_type
;
945 wbc_status
= wbcLookupSid(sid
, &domain
, &name
, &name_type
);
946 BAIL_ON_WBC_ERROR(wbc_status
);
948 if (name_type
== WBC_SID_NAME_USER
) {
952 wbc_status
= wbcSidToUid(sid
, &uid
);
953 BAIL_ON_WBC_ERROR(wbc_status
);
955 wbc_status
= wbcGetpwuid(uid
, &pwd
);
956 BAIL_ON_WBC_ERROR(wbc_status
);
960 name
= wbcStrDup(pwd
->pw_gecos
);
962 BAIL_ON_PTR_ERROR(name
, wbc_status
);
965 wbc_status
= WBC_ERR_SUCCESS
;
968 if (WBC_ERROR_IS_OK(wbc_status
)) {
971 *pname_type
= name_type
;
973 wbcFreeMemory(domain
);
980 const char* wbcSidTypeString(enum wbcSidType type
)
983 case WBC_SID_NAME_USE_NONE
: return "SID_NONE";
984 case WBC_SID_NAME_USER
: return "SID_USER";
985 case WBC_SID_NAME_DOM_GRP
: return "SID_DOM_GROUP";
986 case WBC_SID_NAME_DOMAIN
: return "SID_DOMAIN";
987 case WBC_SID_NAME_ALIAS
: return "SID_ALIAS";
988 case WBC_SID_NAME_WKN_GRP
: return "SID_WKN_GROUP";
989 case WBC_SID_NAME_DELETED
: return "SID_DELETED";
990 case WBC_SID_NAME_INVALID
: return "SID_INVALID";
991 case WBC_SID_NAME_UNKNOWN
: return "SID_UNKNOWN";
992 case WBC_SID_NAME_COMPUTER
: return "SID_COMPUTER";
993 default: return "Unknown type";