summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Nagy <mnagy@redhat.com>2009-09-04 14:06:24 +0200
committerMartin Nagy <mnagy@redhat.com>2009-09-04 14:28:02 +0200
commit0257e00561658908365a58da5acd8051f057b747 (patch)
treed4bfad21aaf612fcb32325036f1c524cdb23693d
parent7d0cba19f4c3b783465775a5616824e1502e7e5a (diff)
downloadldap_driver-0257e00561658908365a58da5acd8051f057b747.tar.gz
ldap_driver-0257e00561658908365a58da5acd8051f057b747.tar.xz
ldap_driver-0257e00561658908365a58da5acd8051f057b747.zip
Fix the reconnection code
We only did a new ldap bind with the old ldap handle, which didn't work. We fix this by getting rid of the old handle and do a brand new init and bind. Resolves ticket #20
-rw-r--r--src/ldap_helper.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/ldap_helper.c b/src/ldap_helper.c
index 8db8851..112c763 100644
--- a/src/ldap_helper.c
+++ b/src/ldap_helper.c
@@ -1523,10 +1523,11 @@ ldap_connect(ldap_connection_t *ldap_conn)
LDAP_OPT_CHECK(ret, "failed to set timeout: %s", ldap_err2string(ret));
*/
+ if (ldap_conn->handle != NULL)
+ ldap_unbind_ext_s(ldap_conn->handle, NULL, NULL);
ldap_conn->handle = ld;
- ldap_reconnect(ldap_conn);
- return ISC_R_SUCCESS;
+ return ldap_reconnect(ldap_conn);
cleanup:
@@ -1646,11 +1647,10 @@ handle_connection_error(ldap_connection_t *ldap_conn, isc_result_t *result)
*result = ISC_R_SUCCESS;
ldap_conn->tries = 0;
return 0;
- } else if (err_code == LDAP_SERVER_DOWN) {
+ } else if (err_code == LDAP_SERVER_DOWN || LDAP_CONNECT_ERROR) {
if (ldap_conn->tries == 0)
log_error("connection to the LDAP server was lost");
- *result = ldap_reconnect(ldap_conn);
- if (*result == ISC_R_SUCCESS)
+ if (ldap_connect(ldap_conn) == ISC_R_SUCCESS)
return 1;
} else {
err_string = ldap_err2string(err_code);