Mercurial > dovecot > core-2.2
changeset 1182:27fb52c532a4 HEAD
Handle LDAP failures better.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Mon, 17 Feb 2003 16:57:23 +0200 |
parents | ac7dbb236b59 |
children | cacfd1b16626 |
files | src/auth/db-ldap.c src/auth/passdb-ldap.c src/auth/userdb-ldap.c |
diffstat | 3 files changed, 18 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/src/auth/db-ldap.c Mon Feb 17 15:38:38 2003 +0200 +++ b/src/auth/db-ldap.c Mon Feb 17 16:57:23 2003 +0200 @@ -55,6 +55,7 @@ static struct ldap_connection *ldap_connections = NULL; static int ldap_conn_open(struct ldap_connection *conn); +static void ldap_conn_close(struct ldap_connection *conn); static int deref2str(const char *str) { @@ -142,6 +143,8 @@ if (ret < 0) { i_error("LDAP: ldap_result() failed: %s", get_ldap_error(conn)); + /* reconnect */ + ldap_conn_close(conn); } return; } @@ -195,8 +198,13 @@ until it's done. */ ret = ldap_simple_bind_s(conn->ld, conn->set.dn, conn->set.dnpass); if (ret != LDAP_SUCCESS) { - i_error("LDAP: ldap_simple_bind_s() failed: %s", - ldap_err2string(ret)); + if (ret == LDAP_SERVER_DOWN) { + i_error("LDAP: Can't connect to server: %s", + conn->set.hosts); + } else { + i_error("LDAP: ldap_simple_bind_s() failed: %s", + ldap_err2string(ret)); + } return FALSE; }
--- a/src/auth/passdb-ldap.c Mon Feb 17 15:38:38 2003 +0200 +++ b/src/auth/passdb-ldap.c Mon Feb 17 16:57:23 2003 +0200 @@ -66,10 +66,11 @@ password = NULL; - entry = ldap_first_entry(conn->ld, res); - if (entry == NULL) - i_error("ldap(%s): unknown user", user); - else { + entry = res == NULL ? NULL : ldap_first_entry(conn->ld, res); + if (entry == NULL) { + if (res != NULL) + i_error("ldap(%s): unknown user", user); + } else { attr = ldap_first_attribute(conn->ld, entry, &ber); while (attr != NULL) { vals = ldap_get_values(conn->ld, entry, attr);
--- a/src/auth/userdb-ldap.c Mon Feb 17 15:38:38 2003 +0200 +++ b/src/auth/userdb-ldap.c Mon Feb 17 16:57:23 2003 +0200 @@ -97,9 +97,10 @@ BerElement *ber; char *attr, **vals; - entry = ldap_first_entry(conn->ld, res); + entry = res == NULL ? NULL : ldap_first_entry(conn->ld, res); if (entry == NULL) { - i_error("LDAP: ldap_first_entry failed()"); + if (res != NULL) + i_error("LDAP: Authenticated user not found"); urequest->userdb_callback(NULL, request->context); return; }