summaryrefslogtreecommitdiff
path: root/source3/nsswitch
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2008-03-23 22:41:45 +0100
committerStefan Metzmacher <metze@samba.org>2008-03-28 15:11:41 +0100
commit87ea917e5daa345a2468de89add556a67d672a13 (patch)
tree2a088009eefc753f6c96af7015578cdaf17e6774 /source3/nsswitch
parentbfbd74f0590fdb16602a37a317a2cd88e600e6f6 (diff)
downloadsamba-87ea917e5daa345a2468de89add556a67d672a13.tar.gz
samba-87ea917e5daa345a2468de89add556a67d672a13.tar.bz2
samba-87ea917e5daa345a2468de89add556a67d672a13.zip
wbinfo: use wbcLookupUserSids()
metze (This used to be commit ff16b66631bc93909c0e7adf9e6bb1cf1d641ffd)
Diffstat (limited to 'source3/nsswitch')
-rw-r--r--source3/nsswitch/wbinfo.c76
1 files changed, 45 insertions, 31 deletions
diff --git a/source3/nsswitch/wbinfo.c b/source3/nsswitch/wbinfo.c
index ee51cce835..ababab367c 100644
--- a/source3/nsswitch/wbinfo.c
+++ b/source3/nsswitch/wbinfo.c
@@ -232,58 +232,72 @@ static bool wbinfo_get_usergroups(char *user)
/* List group SIDs a user SID is a member of */
-static bool wbinfo_get_usersids(char *user_sid)
+static bool wbinfo_get_usersids(const char *user_sid_str)
{
- struct winbindd_request request;
- struct winbindd_response response;
- NSS_STATUS result;
- int i;
- const char *s;
-
- ZERO_STRUCT(request);
- ZERO_STRUCT(response);
+ wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE;
+ uint32_t num_sids;
+ uint32_t i;
+ struct wbcDomainSid user_sid, *sids = NULL;
/* Send request */
- fstrcpy(request.data.sid, user_sid);
- result = winbindd_request_response(WINBINDD_GETUSERSIDS, &request, &response);
+ wbc_status = wbcStringToSid(user_sid_str, &user_sid);
+ if (!WBC_ERROR_IS_OK(wbc_status)) {
+ return false;
+ }
- if (result != NSS_STATUS_SUCCESS)
+ wbc_status = wbcLookupUserSids(&user_sid, false, &num_sids, &sids);
+ if (!WBC_ERROR_IS_OK(wbc_status)) {
return false;
+ }
- s = (const char *)response.extra_data.data;
- for (i = 0; i < response.data.num_entries; i++) {
- d_printf("%s\n", s);
- s += strlen(s) + 1;
+ for (i = 0; i < num_sids; i++) {
+ char *str = NULL;
+ wbc_status = wbcSidToString(&sids[i], &str);
+ if (!WBC_ERROR_IS_OK(wbc_status)) {
+ wbcFreeMemory(sids);
+ return false;
+ }
+ d_printf("%s\n", str);
+ wbcFreeMemory(str);
}
- SAFE_FREE(response.extra_data.data);
+ wbcFreeMemory(sids);
return true;
}
-static bool wbinfo_get_userdomgroups(const char *user_sid)
+static bool wbinfo_get_userdomgroups(const char *user_sid_str)
{
- struct winbindd_request request;
- struct winbindd_response response;
- NSS_STATUS result;
-
- ZERO_STRUCT(request);
- ZERO_STRUCT(response);
+ wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE;
+ uint32_t num_sids;
+ uint32_t i;
+ struct wbcDomainSid user_sid, *sids = NULL;
/* Send request */
- fstrcpy(request.data.sid, user_sid);
- result = winbindd_request_response(WINBINDD_GETUSERDOMGROUPS, &request,
- &response);
+ wbc_status = wbcStringToSid(user_sid_str, &user_sid);
+ if (!WBC_ERROR_IS_OK(wbc_status)) {
+ return false;
+ }
- if (result != NSS_STATUS_SUCCESS)
+ wbc_status = wbcLookupUserSids(&user_sid, true, &num_sids, &sids);
+ if (!WBC_ERROR_IS_OK(wbc_status)) {
return false;
+ }
- if (response.data.num_entries != 0)
- printf("%s", (char *)response.extra_data.data);
+ for (i = 0; i < num_sids; i++) {
+ char *str = NULL;
+ wbc_status = wbcSidToString(&sids[i], &str);
+ if (!WBC_ERROR_IS_OK(wbc_status)) {
+ wbcFreeMemory(sids);
+ return false;
+ }
+ d_printf("%s\n", str);
+ wbcFreeMemory(str);
+ }
- SAFE_FREE(response.extra_data.data);
+ wbcFreeMemory(sids);
return true;
}