From 5980e74d4cac49f73f4170e60f818990537e4471 Mon Sep 17 00:00:00 2001 From: Jim McDonough Date: Thu, 14 Mar 2002 17:56:33 +0000 Subject: 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. (This used to be commit 9c447920dfbae2e2d2343600401c1d860dad863b) --- source3/utils/net_ads.c | 53 +++++++++++++++++++++++++++++-------------------- 1 file changed, 32 insertions(+), 21 deletions(-) diff --git a/source3/utils/net_ads.c b/source3/utils/net_ads.c index 22e511760c..091c254d88 100644 --- a/source3/utils/net_ads.c +++ b/source3/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; } -- cgit