diff options
author | Jim McDonough <jmcd@samba.org> | 2002-03-14 17:56:33 +0000 |
---|---|---|
committer | Jim McDonough <jmcd@samba.org> | 2002-03-14 17:56:33 +0000 |
commit | 9c447920dfbae2e2d2343600401c1d860dad863b (patch) | |
tree | 479df1e06db8f3b5926d8fa2b3655ea88f007531 | |
parent | 9afba67f9a56699e34735e1e425f97b2464f2402 (diff) | |
download | samba-9c447920dfbae2e2d2343600401c1d860dad863b.tar.gz samba-9c447920dfbae2e2d2343600401c1d860dad863b.tar.xz samba-9c447920dfbae2e2d2343600401c1d860dad863b.zip |
Add paged search requests to net ads user and net ads group commands, allowing more than 1000 (or whatever the query limit is on the server) objects to be returned. Printers will come next.
-rw-r--r-- | source/utils/net_ads.c | 53 |
1 files changed, 32 insertions, 21 deletions
diff --git a/source/utils/net_ads.c b/source/utils/net_ads.c index 22e511760c3..091c254d883 100644 --- a/source/utils/net_ads.c +++ b/source/utils/net_ads.c @@ -125,21 +125,26 @@ static int net_ads_user(int argc, const char **argv) ADS_STRUCT *ads; ADS_STATUS rc; void *res; + int rescount; + void *cookie = NULL; const char *attrs[] = {"sAMAccountName", "name", "objectSid", NULL}; - + if (!(ads = ads_startup())) return -1; - rc = ads_search(ads, &res, "(objectclass=user)", attrs); - if (!ADS_ERR_OK(rc)) { - d_printf("ads_search: %s\n", ads_errstr(rc)); - return -1; - } - if (ads_count_replies(ads, res) == 0) { - d_printf("No users found\n"); - return -1; - } + do { + rc = ads_do_paged_search(ads, ads->bind_path, + LDAP_SCOPE_SUBTREE, + "(objectclass=user)", attrs, &res, + &rescount, &cookie); + + if (!ADS_ERR_OK(rc)) { + d_printf("ads_search: %s\n", ads_errstr(rc)); + return -1; + } + ads_dump(ads, res); + + } while (cookie); - ads_dump(ads, res); ads_destroy(&ads); return 0; } @@ -149,21 +154,27 @@ static int net_ads_group(int argc, const char **argv) ADS_STRUCT *ads; ADS_STATUS rc; void *res; + int rescount; + void *cookie = NULL; const char *attrs[] = {"sAMAccountName", "name", "objectSid", NULL}; if (!(ads = ads_startup())) return -1; - rc = ads_search(ads, &res, "(objectclass=group)", attrs); - if (!ADS_ERR_OK(rc)) { - d_printf("ads_search: %s\n", ads_errstr(rc)); - return -1; - } - if (ads_count_replies(ads, res) == 0) { - d_printf("No groups found\n"); - return -1; - } + do { + rc = ads_do_paged_search(ads, ads->bind_path, + LDAP_SCOPE_SUBTREE, + "(objectclass=group)", attrs, &res, + &rescount, &cookie); - ads_dump(ads, res); + if (!ADS_ERR_OK(rc)) { + d_printf("ads_search: %s\n", ads_errstr(rc)); + return -1; + } + ads_dump(ads, res); + + } while (cookie); + + ads_destroy(&ads); return 0; } |