summaryrefslogtreecommitdiff
path: root/source3/nsswitch
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2008-03-24 20:32:14 +0100
committerStefan Metzmacher <metze@samba.org>2008-03-28 15:11:42 +0100
commit8686d47bad3b1ea59834974c30a5b380677db429 (patch)
tree462adfbee981a3f8084e9643bcfd317e57f5610d /source3/nsswitch
parent87ea917e5daa345a2468de89add556a67d672a13 (diff)
downloadsamba-8686d47bad3b1ea59834974c30a5b380677db429.tar.gz
samba-8686d47bad3b1ea59834974c30a5b380677db429.tar.bz2
samba-8686d47bad3b1ea59834974c30a5b380677db429.zip
wbinfo: use wbcListUsers() and wbcListGroups()
metze (This used to be commit 5a0ae1ad0c36e5ef97008a2c6bc2a921ca6538bd)
Diffstat (limited to 'source3/nsswitch')
-rw-r--r--source3/nsswitch/wbinfo.c83
1 files changed, 29 insertions, 54 deletions
diff --git a/source3/nsswitch/wbinfo.c b/source3/nsswitch/wbinfo.c
index ababab367c..f8d77cec60 100644
--- a/source3/nsswitch/wbinfo.c
+++ b/source3/nsswitch/wbinfo.c
@@ -1074,42 +1074,28 @@ static bool wbinfo_klog(char *username)
static bool print_domain_users(const char *domain)
{
- struct winbindd_request request;
- struct winbindd_response response;
- const char *extra_data;
- char *name;
- TALLOC_CTX *frame = NULL;
+ wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE;
+ uint32_t i;
+ uint32_t num_users = 0;
+ const char **users = NULL;
/* Send request to winbind daemon */
- ZERO_STRUCT(request);
- ZERO_STRUCT(response);
-
- if (domain) {
- /* '.' is the special sign for our own domain */
- if ( strequal(domain, ".") )
- fstrcpy( request.domain_name, get_winbind_domain() );
- else
- fstrcpy( request.domain_name, domain );
+ /* '.' is the special sign for our own domain */
+ if (domain && strcmp(domain, ".") == 0) {
+ domain = get_winbind_domain();
}
- if (winbindd_request_response(WINBINDD_LIST_USERS, &request, &response) !=
- NSS_STATUS_SUCCESS)
- return false;
-
- /* Look through extra data */
-
- if (!response.extra_data.data)
+ wbc_status = wbcListUsers(domain, &num_users, &users);
+ if (!WBC_ERROR_IS_OK(wbc_status)) {
return false;
+ }
- extra_data = (const char *)response.extra_data.data;
-
- frame = talloc_stackframe();
- while(next_token_talloc(frame,&extra_data,&name, ","))
- d_printf("%s\n", name);
- TALLOC_FREE(frame);
+ for (i=0; i < num_users; i++) {
+ d_printf("%s\n", users[i]);
+ }
- SAFE_FREE(response.extra_data.data);
+ wbcFreeMemory(users);
return true;
}
@@ -1118,39 +1104,28 @@ static bool print_domain_users(const char *domain)
static bool print_domain_groups(const char *domain)
{
- struct winbindd_request request;
- struct winbindd_response response;
- const char *extra_data;
- TALLOC_CTX *frame = NULL;
- char *name;
+ wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE;
+ uint32_t i;
+ uint32_t num_groups = 0;
+ const char **groups = NULL;
- ZERO_STRUCT(request);
- ZERO_STRUCT(response);
+ /* Send request to winbind daemon */
- if (domain) {
- if ( strequal(domain, ".") )
- fstrcpy( request.domain_name, get_winbind_domain() );
- else
- fstrcpy( request.domain_name, domain );
+ /* '.' is the special sign for our own domain */
+ if (domain && strcmp(domain, ".") == 0) {
+ domain = get_winbind_domain();
}
- if (winbindd_request_response(WINBINDD_LIST_GROUPS, &request, &response) !=
- NSS_STATUS_SUCCESS)
- return false;
-
- /* Look through extra data */
-
- if (!response.extra_data.data)
+ wbc_status = wbcListGroups(domain, &num_groups, &groups);
+ if (!WBC_ERROR_IS_OK(wbc_status)) {
return false;
+ }
- extra_data = (const char *)response.extra_data.data;
-
- frame = talloc_stackframe();
- while(next_token_talloc(frame,&extra_data,&name, ","))
- d_printf("%s\n", name);
- TALLOC_FREE(frame);
+ for (i=0; i < num_groups; i++) {
+ d_printf("%s\n", groups[i]);
+ }
- SAFE_FREE(response.extra_data.data);
+ wbcFreeMemory(groups);
return true;
}