summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2008-04-02 06:03:48 +0200
committerStefan Metzmacher <metze@samba.org>2008-04-03 15:49:18 +0200
commitf963e50de71ce7a5859b59f90685f880c37293f4 (patch)
treeca5ee5a6248b80f706fd797f52a3e1a565fc38a4
parent421f9d2e6b36fa2aa54275018375085db4ca7e13 (diff)
downloadsamba-f963e50de71ce7a5859b59f90685f880c37293f4.tar.gz
samba-f963e50de71ce7a5859b59f90685f880c37293f4.tar.bz2
samba-f963e50de71ce7a5859b59f90685f880c37293f4.zip
wbinfo: use wbcLookupRids()
metze (This used to be commit 046b26b763b16362dd662a77b2434641bf583bc2)
-rw-r--r--source3/nsswitch/wbinfo.c73
1 files changed, 40 insertions, 33 deletions
diff --git a/source3/nsswitch/wbinfo.c b/source3/nsswitch/wbinfo.c
index aac9f3fcb9..f43d54a744 100644
--- a/source3/nsswitch/wbinfo.c
+++ b/source3/nsswitch/wbinfo.c
@@ -803,46 +803,38 @@ static bool wbinfo_lookupsid(const char *sid_str)
/* Lookup a list of RIDs */
-static bool wbinfo_lookuprids(char *domain, char *arg)
+static bool wbinfo_lookuprids(const char *domain, const char *arg)
{
+ wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE;
+ struct wbcDomainInfo *dinfo = NULL;
+ char *domain_name = NULL;
+ const char **names = NULL;
+ enum wbcSidType *types = NULL;
size_t i;
- DOM_SID sid;
int num_rids;
- uint32 *rids;
+ uint32 *rids = NULL;
const char *p;
char *ridstr;
- const char **names;
- enum lsa_SidType *types;
- const char *domain_name;
TALLOC_CTX *mem_ctx;
- struct winbindd_request request;
- struct winbindd_response response;
-
- ZERO_STRUCT(request);
- ZERO_STRUCT(response);
+ bool ret = false;
- if ((domain == NULL) || (strequal(domain, ".")) || (domain[0] == '\0'))
- fstrcpy(request.domain_name, get_winbind_domain());
- else
- fstrcpy(request.domain_name, domain);
+ if ((domain == NULL) || (strequal(domain, ".")) || (domain[0] == '\0')) {
+ domain = get_winbind_domain();
+ }
/* Send request */
- if (winbindd_request_response(WINBINDD_DOMAIN_INFO, &request, &response) !=
- NSS_STATUS_SUCCESS) {
- d_printf("Could not get domain sid for %s\n", request.domain_name);
- return false;
- }
-
- if (!string_to_sid(&sid, response.data.domain_info.sid)) {
- d_printf("Could not convert %s to sid\n", response.data.domain_info.sid);
- return false;
+ wbc_status = wbcDomainInfo(domain, &dinfo);
+ if (!WBC_ERROR_IS_OK(wbc_status)) {
+ d_printf("wbcDomainInfo(%s) failed: %s\n", domain,
+ wbcErrorString(wbc_status));
+ goto done;
}
mem_ctx = talloc_new(NULL);
if (mem_ctx == NULL) {
d_printf("talloc_new failed\n");
- return false;
+ goto done;
}
num_rids = 0;
@@ -855,15 +847,16 @@ static bool wbinfo_lookuprids(char *domain, char *arg)
}
if (rids == NULL) {
- TALLOC_FREE(mem_ctx);
- return false;
+ d_printf("no rids\n");
+ goto done;
}
- if (!winbind_lookup_rids(mem_ctx, &sid, num_rids, rids,
- &domain_name, &names, &types)) {
- d_printf("winbind_lookup_rids failed\n");
- TALLOC_FREE(mem_ctx);
- return false;
+ wbc_status = wbcLookupRids(&dinfo->sid, num_rids, rids,
+ (const char **)&domain_name, &names, &types);
+ if (!WBC_ERROR_IS_OK(wbc_status)) {
+ d_printf("winbind_lookup_rids failed: %s\n",
+ wbcErrorString(wbc_status));
+ goto done;
}
d_printf("Domain: %s\n", domain_name);
@@ -873,8 +866,22 @@ static bool wbinfo_lookuprids(char *domain, char *arg)
sid_type_lookup(types[i]));
}
+ ret = true;
+done:
+ if (dinfo) {
+ wbcFreeMemory(dinfo);
+ }
+ if (domain_name) {
+ wbcFreeMemory(domain_name);
+ }
+ if (names) {
+ wbcFreeMemory(names);
+ }
+ if (types) {
+ wbcFreeMemory(types);
+ }
TALLOC_FREE(mem_ctx);
- return true;
+ return ret;
}
/* Convert string to sid */