diff options
author | Jim McDonough <jmcd@samba.org> | 2002-04-05 19:28:02 +0000 |
---|---|---|
committer | Jim McDonough <jmcd@samba.org> | 2002-04-05 19:28:02 +0000 |
commit | 3fcb31db922f911a713c89bb2ee626042e41df46 (patch) | |
tree | 3f781f40e8650b616cfecff1adda47305b9acc4b /source3/utils | |
parent | 40260fdaf906d7f4d71a461f294e3c99b564d13c (diff) | |
download | samba-3fcb31db922f911a713c89bb2ee626042e41df46.tar.gz samba-3fcb31db922f911a713c89bb2ee626042e41df46.tar.bz2 samba-3fcb31db922f911a713c89bb2ee626042e41df46.zip |
Use the new ads_do_search_all2 function. It provides sorted results. We now
also filter out users that end in '$', which gives us the same results as
the net rpc user and net rap user.
(This used to be commit e3a813831276ec2aafa0caa4f4fed0785dcdb749)
Diffstat (limited to 'source3/utils')
-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; |