diff options
Diffstat (limited to 'source3/nsswitch')
-rw-r--r-- | source3/nsswitch/wbinfo.c | 83 |
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; } |