summaryrefslogtreecommitdiff
path: root/source3/libads/ldap.c
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2002-03-19 22:14:53 +0000
committerAndrew Tridgell <tridge@samba.org>2002-03-19 22:14:53 +0000
commitb462700e53df7fa64a4cd019054eae9e7f746aef (patch)
tree121644745bf53ef782fa4c5b5aeba98b717167fc /source3/libads/ldap.c
parent050b80356edea52f1bbb0a27599186ad84c18b73 (diff)
downloadsamba-b462700e53df7fa64a4cd019054eae9e7f746aef.tar.gz
samba-b462700e53df7fa64a4cd019054eae9e7f746aef.tar.bz2
samba-b462700e53df7fa64a4cd019054eae9e7f746aef.zip
added a ads_do_search_all() call, which is a more convenient interface
to paged searches. This makes updating winbindd to used paged searches trivial. (This used to be commit 514c11b4e3fcc765a8087405333bd351c05c9e36)
Diffstat (limited to 'source3/libads/ldap.c')
-rw-r--r--source3/libads/ldap.c42
1 files changed, 42 insertions, 0 deletions
diff --git a/source3/libads/ldap.c b/source3/libads/ldap.c
index 8d865dd113..c8661c2ebb 100644
--- a/source3/libads/ldap.c
+++ b/source3/libads/ldap.c
@@ -99,6 +99,7 @@ ADS_STATUS ads_do_paged_search(ADS_STRUCT *ads, const char *bind_path,
if (cookie && *cookie) {
ber_printf(berelem, "{iO}", (ber_int_t) 1000, *cookie);
ber_bvfree(*cookie); /* don't need it from last time */
+ *cookie = NULL;
} else {
ber_printf(berelem, "{io}", (ber_int_t) 1000, "", 0);
}
@@ -160,6 +161,47 @@ ADS_STATUS ads_do_paged_search(ADS_STRUCT *ads, const char *bind_path,
return ADS_ERROR(rc);
}
+
+/*
+ this uses ads_do_paged_search() to return all entries in a large
+ search. The interface is the same as ads_do_search(), which makes
+ it more convenient than the paged interface
+ */
+ADS_STATUS ads_do_search_all(ADS_STRUCT *ads, const char *bind_path,
+ int scope, const char *exp,
+ const char **attrs, void **res)
+{
+ void *cookie = NULL;
+ int count = 0;
+ ADS_STATUS status;
+
+ status = ads_do_paged_search(ads, bind_path, scope, exp, attrs, res, &count, &cookie);
+
+ if (!ADS_ERR_OK(status)) return status;
+
+ while (cookie) {
+ void *res2 = NULL;
+ ADS_STATUS status2;
+ LDAPMessage *msg, *next;
+
+ status2 = ads_do_paged_search(ads, bind_path, scope, exp, attrs, &res2, &count, &cookie);
+
+ if (!ADS_ERR_OK(status2)) break;
+
+ /* this relies on the way that ldap_add_result_entry() works internally. I hope
+ that this works on all ldap libs, but I have only tested with openldap */
+ for (msg = ads_first_entry(ads, res2); msg; msg = next) {
+ next = ads_next_entry(ads, msg);
+ ldap_add_result_entry((LDAPMessage **)res, msg);
+ }
+
+ /* note that we do not free res2, as the memory is now
+ part of the main returned list */
+ }
+
+ return status;
+}
+
/*
do a search with a timeout
*/