[dovecot-cvs] dovecot/src/auth db-ldap.c,1.8,1.9 passdb-ldap.c,1.2,1.3 userdb-ldap.c,1.6,1.7
cras at procontrol.fi
cras at procontrol.fi
Mon Feb 17 16:57:25 EET 2003
Update of /home/cvs/dovecot/src/auth
In directory danu:/tmp/cvs-serv11377/auth
Modified Files:
db-ldap.c passdb-ldap.c userdb-ldap.c
Log Message:
Handle LDAP failures better.
Index: db-ldap.c
===================================================================
RCS file: /home/cvs/dovecot/src/auth/db-ldap.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- db-ldap.c 17 Feb 2003 13:38:38 -0000 1.8
+++ db-ldap.c 17 Feb 2003 14:57:23 -0000 1.9
@@ -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;
}
Index: passdb-ldap.c
===================================================================
RCS file: /home/cvs/dovecot/src/auth/passdb-ldap.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- passdb-ldap.c 11 Feb 2003 10:11:31 -0000 1.2
+++ passdb-ldap.c 17 Feb 2003 14:57:23 -0000 1.3
@@ -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);
Index: userdb-ldap.c
===================================================================
RCS file: /home/cvs/dovecot/src/auth/userdb-ldap.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- userdb-ldap.c 11 Feb 2003 12:53:56 -0000 1.6
+++ userdb-ldap.c 17 Feb 2003 14:57:23 -0000 1.7
@@ -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;
}
More information about the dovecot-cvs
mailing list