s3-libads: Use a reducing page size to try and cope with a slow LDAP server
[samba.git] / source3 / libads / ldap_utils.c
index 871449a81af4bc8233b1ab2571d432757afae890..dee3c03a2166dd22febea561977cc62f28fd9233 100644 (file)
@@ -68,6 +68,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;