summaryrefslogtreecommitdiff
path: root/source3/libads
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2012-05-18 22:01:14 +1000
committerJeremy Allison <jra@samba.org>2012-05-26 02:03:08 +0200
commit0da10c842e06e98cf94482b654b87ff5991344ae (patch)
treefe55f0fb094ce6f6a44b59d4f292a959475be0ea /source3/libads
parentb9217a8c0032c10b898a4f1ca0ed8d38f39c39a1 (diff)
downloadsamba-0da10c842e06e98cf94482b654b87ff5991344ae.tar.gz
samba-0da10c842e06e98cf94482b654b87ff5991344ae.tar.bz2
samba-0da10c842e06e98cf94482b654b87ff5991344ae.zip
s3-libads: Use a reducing page size to try and cope with a slow LDAP server
If we cannot get 1000 users downloaded in 15seconds, try with 500, 250 and then 125 users at a time. Andrew Bartlett Signed-off-by: Jeremy Allison <jra@samba.org>
Diffstat (limited to 'source3/libads')
-rw-r--r--source3/libads/ads_struct.c4
-rw-r--r--source3/libads/ldap.c4
-rw-r--r--source3/libads/ldap_utils.c7
3 files changed, 13 insertions, 2 deletions
diff --git a/source3/libads/ads_struct.c b/source3/libads/ads_struct.c
index e6220fd320..285057ba53 100644
--- a/source3/libads/ads_struct.c
+++ b/source3/libads/ads_struct.c
@@ -156,6 +156,10 @@ ADS_STRUCT *ads_init(const char *realm,
ads->auth.flags = wrap_flags;
+ /* Start with a page size of 1000 when the connection is new,
+ * we will drop it by half we get a timeout. */
+ ads->config.ldap_page_size = 1000;
+
return ads;
}
diff --git a/source3/libads/ldap.c b/source3/libads/ldap.c
index f3987c99c1..5c77df1ade 100644
--- a/source3/libads/ldap.c
+++ b/source3/libads/ldap.c
@@ -954,11 +954,11 @@ static ADS_STATUS ads_do_paged_search_args(ADS_STRUCT *ads,
cookie_be = ber_alloc_t(LBER_USE_DER);
if (*cookie) {
- ber_printf(cookie_be, "{iO}", (ber_int_t) 1000, *cookie);
+ ber_printf(cookie_be, "{iO}", (ber_int_t) ads->config.ldap_page_size, *cookie);
ber_bvfree(*cookie); /* don't need it from last time */
*cookie = NULL;
} else {
- ber_printf(cookie_be, "{io}", (ber_int_t) 1000, "", 0);
+ ber_printf(cookie_be, "{io}", (ber_int_t) ads->config.ldap_page_size, "", 0);
}
ber_flatten(cookie_be, &cookie_bv);
PagedResults.ldctl_oid = discard_const_p(char, ADS_PAGE_CTL_OID);
diff --git a/source3/libads/ldap_utils.c b/source3/libads/ldap_utils.c
index 2f1c1b8e0a..8a4b452b87 100644
--- a/source3/libads/ldap_utils.c
+++ b/source3/libads/ldap_utils.c
@@ -84,6 +84,13 @@ static ADS_STATUS ads_do_search_retry_internal(ADS_STRUCT *ads, const char *bind
while (--count) {
+ if (NT_STATUS_EQUAL(ads_ntstatus(status), NT_STATUS_IO_TIMEOUT) && ads->config.ldap_page_size >= 250) {
+ int new_page_size = (ads->config.ldap_page_size / 2);
+ DEBUG(1, ("Reducing LDAP page size from %d to %d due to IO_TIMEOUT\n",
+ ads->config.ldap_page_size, new_page_size));
+ ads->config.ldap_page_size = new_page_size;
+ }
+
if (*res)
ads_msgfree(ads, *res);
*res = NULL;