diff options
-rw-r--r-- | source3/utils/net_ads.c | 48 |
1 files changed, 18 insertions, 30 deletions
diff --git a/source3/utils/net_ads.c b/source3/utils/net_ads.c index 260f49ee76..922e1331cd 100644 --- a/source3/utils/net_ads.c +++ b/source3/utils/net_ads.c @@ -144,11 +144,13 @@ static void usergrp_display(char *field, void **values, void *data_area) char **disp_fields = (char **) data_area; if (!field) { /* must be end of record */ - if (disp_fields[1]) - printf("%-21.21s %-50.50s\n", - disp_fields[0], disp_fields[1]); - else - printf("%s\n", disp_fields[0]); + if (!strchr_m(disp_fields[0], '$')) { + if (disp_fields[1]) + printf("%-21.21s %-50.50s\n", + disp_fields[0], disp_fields[1]); + else + printf("%-21.21s\n", disp_fields[0]); + } SAFE_FREE(disp_fields[0]); SAFE_FREE(disp_fields[1]); return; @@ -287,7 +289,6 @@ int net_ads_user(int argc, const char **argv) }; ADS_STRUCT *ads; ADS_STATUS rc; - void *res; const char *shortattrs[] = {"sAMAccountName", NULL}; const char *longattrs[] = {"sAMAccountName", "description", NULL}; extern int opt_long_list_entries; @@ -296,22 +297,17 @@ int net_ads_user(int argc, const char **argv) if (argc == 0) { if (!(ads = ads_startup())) return -1; - rc = ads_do_search_all(ads, ads->bind_path, LDAP_SCOPE_SUBTREE, - "(objectclass=user)", - opt_long_list_entries ? - longattrs : shortattrs, &res); - - if (!ADS_ERR_OK(rc)) { - d_printf("ads_search: %s\n", ads_errstr(rc)); - return -1; - } - if (opt_long_list_entries) d_printf("\nUser name Comment"\ "\n-----------------------------\n"); - ads_process_results(ads, res, usergrp_display, disp_fields); - ads_msgfree(ads, res); + rc = ads_do_search_all2(ads, ads->bind_path, + LDAP_SCOPE_SUBTREE, + "(objectclass=user)", + opt_long_list_entries ? + longattrs : shortattrs, + "sAMAccountName", usergrp_display, + disp_fields); ads_destroy(&ads); return 0; } @@ -323,7 +319,6 @@ static int net_ads_group(int argc, const char **argv) { ADS_STRUCT *ads; ADS_STATUS rc; - void *res; const char *shortattrs[] = {"sAMAccountName", NULL}; const char *longattrs[] = {"sAMAccountName", "description", NULL}; extern int opt_long_list_entries; @@ -331,20 +326,13 @@ static int net_ads_group(int argc, const char **argv) if (!(ads = ads_startup())) return -1; - rc = ads_do_search_all(ads, ads->bind_path, LDAP_SCOPE_SUBTREE, - "(objectclass=group)", opt_long_list_entries ? - longattrs : shortattrs, &res); - - if (!ADS_ERR_OK(rc)) { - d_printf("ads_search: %s\n", ads_errstr(rc)); - return -1; - } - if (opt_long_list_entries) d_printf("\nGroup name Comment"\ "\n-----------------------------\n"); - ads_process_results(ads, res, usergrp_display, disp_fields); - ads_msgfree(ads, res); + rc = ads_do_search_all2(ads, ads->bind_path, LDAP_SCOPE_SUBTREE, + "(objectclass=group)", opt_long_list_entries ? + longattrs : shortattrs, "sAMAccountName", + usergrp_display, disp_fields); ads_destroy(&ads); return 0; |