diff options
author | Jeremy Allison <jra@samba.org> | 2008-04-17 09:25:45 -0700 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2008-04-17 09:25:45 -0700 |
commit | 78d88cbaeb21915ffdba45f1844cfd2a8534c874 (patch) | |
tree | 5ceb07b818ff30cbd02f8c5ef7f842864595950a /source3/nsswitch/wbinfo.c | |
parent | 4939a24cbc751719b008bdd474181fffabd33934 (diff) | |
parent | 5c29bc8931d025de4ec91247be04da4388642727 (diff) | |
download | samba-78d88cbaeb21915ffdba45f1844cfd2a8534c874.tar.gz samba-78d88cbaeb21915ffdba45f1844cfd2a8534c874.tar.bz2 samba-78d88cbaeb21915ffdba45f1844cfd2a8534c874.zip |
Merge branch 'v3-2-test' of ssh://jra@git.samba.org/data/git/samba into v3-2-test
(This used to be commit d665cecd8b1b40ad30ec435de0bd925cdea24795)
Diffstat (limited to 'source3/nsswitch/wbinfo.c')
-rw-r--r-- | source3/nsswitch/wbinfo.c | 134 |
1 files changed, 50 insertions, 84 deletions
diff --git a/source3/nsswitch/wbinfo.c b/source3/nsswitch/wbinfo.c index 1e943a5eee..ed49be7431 100644 --- a/source3/nsswitch/wbinfo.c +++ b/source3/nsswitch/wbinfo.c @@ -341,101 +341,67 @@ static bool wbinfo_wins_byip(const char *ip) static bool wbinfo_list_domains(bool list_all_domains, bool verbose) { - struct winbindd_request request; - struct winbindd_response response; - + struct wbcDomainInfo *domain_list = NULL; + size_t num_domains; + wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE; bool print_all = !list_all_domains && verbose; + int i; - ZERO_STRUCT(request); - ZERO_STRUCT(response); - - /* Send request */ - - request.data.list_all_domains = list_all_domains; - - if (winbindd_request_response(WINBINDD_LIST_TRUSTDOM, &request, &response) != - NSS_STATUS_SUCCESS) + wbc_status = wbcListTrusts(&domain_list, &num_domains); + if (!WBC_ERROR_IS_OK(wbc_status)) { return false; + } - /* Display response */ + if (print_all) { + d_printf("%-16s%-24s%-12s%-12s%-5s%-5s\n", + "Domain Name", "DNS Domain", "Trust Type", + "Transitive", "In", "Out"); + } - if (response.extra_data.data) { - const char *extra_data = (char *)response.extra_data.data; - char *name; - char *beg, *end; - TALLOC_CTX *frame = talloc_stackframe(); + for (i=0; i<num_domains; i++) { + d_printf("%-16s", domain_list[i].short_name); - if (print_all) { - d_printf("%-16s%-24s%-12s%-12s%-5s%-5s\n", - "Domain Name", "DNS Domain", "Trust Type", - "Transitive", "In", "Out"); + if (!print_all) { + d_printf("\n"); + continue; } - while(next_token_talloc(frame,&extra_data,&name,"\n")) { - /* Print Domain Name */ - if ((beg = strchr(name, '\\')) == NULL) - goto error; - *beg = 0; - beg++; - if ((end = strchr(beg, '\\')) == NULL) - goto error; - *end = 0; - - /* Print short name */ + d_printf("%-24s", domain_list[i].dns_name); - d_printf("%-16s", name); - - if (!print_all) { - d_printf("\n"); - continue; - } + switch(domain_list[i].trust_type) { + case WBC_DOMINFO_TRUSTTYPE_NONE: + d_printf("None "); + break; + case WBC_DOMINFO_TRUSTTYPE_FOREST: + d_printf("Forest "); + break; + case WBC_DOMINFO_TRUSTTYPE_EXTERNAL: + d_printf("External "); + break; + case WBC_DOMINFO_TRUSTTYPE_IN_FOREST: + d_printf("In-Forest "); + break; + } - /* Print DNS domain */ + if (domain_list[i].trust_flags & WBC_DOMINFO_TRUST_TRANSITIVE) { + d_printf("Yes "); + } else { + d_printf("No "); + } - if (beg) { - d_printf("%-24s", beg); - } + if (domain_list[i].trust_flags & WBC_DOMINFO_TRUST_INCOMING) { + d_printf("Yes "); + } else { + d_printf("No "); + } - /* Skip SID */ - beg = ++end; - if ((end = strchr(beg, '\\')) == NULL) - goto error; - - /* Print Trust Type */ - beg = ++end; - if ((end = strchr(beg, '\\')) == NULL) - goto error; - *end = 0; - d_printf("%-12s", beg); - - /* Print Transitive */ - beg = ++end; - if ((end = strchr(beg, '\\')) == NULL) - goto error; - *end = 0; - d_printf("%-12s", beg); - - /* Print Incoming */ - beg = ++end; - if ((end = strchr(beg, '\\')) == NULL) - goto error; - *end = 0; - d_printf("%-5s", beg); - - /* Print Outgoing */ - beg = ++end; - d_printf("%-5s\n", beg); + if (domain_list[i].trust_flags & WBC_DOMINFO_TRUST_OUTGOING) { + d_printf("Yes "); + } else { + d_printf("No "); } - goto out; -error: - d_fprintf(stderr, "Got invalid response: %s\n", extra_data); - TALLOC_FREE(frame); - SAFE_FREE(response.extra_data.data); - return false; -out: - TALLOC_FREE(frame); - SAFE_FREE(response.extra_data.data); + d_printf("\n"); } return true; @@ -519,12 +485,12 @@ static bool wbinfo_domain_info(const char *domain) d_printf("SID : %s\n", sid_str); d_printf("Active Directory : %s\n", - (dinfo->flags & WBC_DOMINFO_AD) ? "Yes" : "No"); + (dinfo->domain_flags & WBC_DOMINFO_AD) ? "Yes" : "No"); d_printf("Native : %s\n", - (dinfo->flags & WBC_DOMINFO_NATIVE) ? "Yes" : "No"); + (dinfo->domain_flags & WBC_DOMINFO_NATIVE) ? "Yes" : "No"); d_printf("Primary : %s\n", - (dinfo->flags & WBC_DOMINFO_PRIMARY) ? "Yes" : "No"); + (dinfo->domain_flags & WBC_DOMINFO_PRIMARY) ? "Yes" : "No"); wbcFreeMemory(sid_str); wbcFreeMemory(dinfo); |