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 | 5980e74d4cac49f73f4170e60f818990537e4471 (patch) | |
tree | 59517807e4e039443199022e8ba57255f7a43e76 | |
parent | 0640a5ceeb974f06dc29669bdbce75fcf7154439 (diff) | |
download | samba-5980e74d4cac49f73f4170e60f818990537e4471.tar.gz samba-5980e74d4cac49f73f4170e60f818990537e4471.tar.bz2 samba-5980e74d4cac49f73f4170e60f818990537e4471.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.
(This used to be commit 9c447920dfbae2e2d2343600401c1d860dad863b)
-rw-r--r-- | source3/utils/net_ads.c | 53 |
1 files 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; } |