summaryrefslogtreecommitdiff
path: root/source3/lib/smbldap.c
diff options
context:
space:
mode:
authorBjörn Jacke <bj@sernet.de>2008-05-26 11:29:24 +0200
committerKarolin Seeger <kseeger@samba.org>2008-06-03 16:32:31 +0200
commitd8b234648cbc18c02d2c79a32be766080c61b42a (patch)
treeeaa0b057581b213dc296a5eb6387624e72030536 /source3/lib/smbldap.c
parent8c7e21679b69eab4319efb484630cddfaf973e36 (diff)
downloadsamba-d8b234648cbc18c02d2c79a32be766080c61b42a.tar.gz
samba-d8b234648cbc18c02d2c79a32be766080c61b42a.tar.bz2
samba-d8b234648cbc18c02d2c79a32be766080c61b42a.zip
Add ldap connection timeout for OpenLDAP and Netscape LDAP libs. This can be controlled via the ldap connection timeout parameter. This fixes fallbacks to secondary LDAP servers in multi LDAP server setups like in #4544
(This used to be commit 8e59a2fedc940b081222b0e8f90fe0c5a0981c06)
Diffstat (limited to 'source3/lib/smbldap.c')
-rw-r--r--source3/lib/smbldap.c26
1 files changed, 25 insertions, 1 deletions
diff --git a/source3/lib/smbldap.c b/source3/lib/smbldap.c
index 9fb16f8927..c2c58c0abf 100644
--- a/source3/lib/smbldap.c
+++ b/source3/lib/smbldap.c
@@ -672,9 +672,33 @@ int smb_ldap_setup_conn(LDAP **ldap_struct, const char *uri)
return LDAP_OPERATIONS_ERROR;
#endif /* LDAP_OPT_X_TLS */
}
-
}
#endif /* HAVE_LDAP_INITIALIZE */
+
+
+ /* now set connection timeout */
+#ifdef LDAP_X_OPT_CONNECT_TIMEOUT /* Netscape */
+ {
+ int ct = lp_ldap_connection_timeout()*1000;
+ rc = ldap_set_option(*ldap_struct, LDAP_X_OPT_CONNECT_TIMEOUT, &ct);
+ if (rc != LDAP_SUCCESS) {
+ DEBUG(0,("Failed to setup an ldap connection timeout %d: %s\n",
+ ct, ldap_err2string(rc)));
+ }
+ }
+#elif defined (LDAP_OPT_NETWORK_TIMEOUT) /* OpenLDAP */
+ {
+ struct timeval ct;
+ ct.tv_usec = 0;
+ ct.tv_sec = lp_ldap_connection_timeout();
+ rc = ldap_set_option(*ldap_struct, LDAP_OPT_NETWORK_TIMEOUT, &ct);
+ if (rc != LDAP_SUCCESS) {
+ DEBUG(0,("Failed to setup an ldap connection timeout %d: %s\n",
+ ct.tv_sec, ldap_err2string(rc)));
+ }
+ }
+#endif
+
return LDAP_SUCCESS;
}