summaryrefslogtreecommitdiffstats
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
commit514c11b4e3fcc765a8087405333bd351c05c9e36 (patch)
tree8fffaadc29b94cec1e88f2792cc55db969c83c71
parentaa4b6f8181f34196a28951264dd8b631a5deef7f (diff)
downloadsamba-514c11b4e3fcc765a8087405333bd351c05c9e36.tar.gz
samba-514c11b4e3fcc765a8087405333bd351c05c9e36.tar.xz
samba-514c11b4e3fcc765a8087405333bd351c05c9e36.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.
-rw-r--r--source/libads/ldap.c42
1 files changed, 42 insertions, 0 deletions
diff --git a/source/libads/ldap.c b/source/libads/ldap.c
index 8d865dd1138..c8661c2ebb2 100644
--- a/source/libads/ldap.c
+++ b/source/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
*/