From: Timo Sirainen Date: Fri, 22 Aug 2003 05:06:53 +0000 (+0300) Subject: Give better error message if uid/gid not found from ldap and no default was X-Git-Tag: 1.1.alpha1~4397 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=002bb664e4b88a808e8a07cf595bfbbf1e7194ec;p=thirdparty%2Fdovecot%2Fcore.git Give better error message if uid/gid not found from ldap and no default was set. --HG-- branch : HEAD --- diff --git a/src/auth/db-ldap.c b/src/auth/db-ldap.c index 10ab9fc44d..fbf17d05f3 100644 --- a/src/auth/db-ldap.c +++ b/src/auth/db-ldap.c @@ -54,8 +54,8 @@ struct ldap_settings default_ldap_settings = { MEMBER(pass_attrs) NULL, MEMBER(pass_filter) NULL, MEMBER(default_pass_scheme) "crypt", - MEMBER(user_global_uid) 0, - MEMBER(user_global_gid) 0 + MEMBER(user_global_uid) (uid_t)-1, + MEMBER(user_global_gid) (gid_t)-1 }; static struct ldap_connection *ldap_connections = NULL; diff --git a/src/auth/userdb-ldap.c b/src/auth/userdb-ldap.c index 37647e06cd..f13afb8d5f 100644 --- a/src/auth/userdb-ldap.c +++ b/src/auth/userdb-ldap.c @@ -127,18 +127,25 @@ static void handle_request(struct ldap_connection *conn, attr = ldap_next_attribute(conn->ld, entry, ber); } - if (user.virtual_user == NULL) { + if (user.virtual_user == NULL) i_error("LDAP: No username in reply"); - urequest->userdb_callback(NULL, request->context); + else if (user.uid == (uid_t)-1) { + i_error("ldap(%s): uidNumber not set and no default given in " + "user_global_uid", user.virtual_user); + } else if (user.gid == (gid_t)-1) { + i_error("ldap(%s): gidNumber not set and no default given in " + "user_global_gid", user.virtual_user); + } else if (ldap_next_entry(conn->ld, entry) != NULL) { + i_error("ldap(%s): Multiple replies found for user", + user.virtual_user); } else { - if (ldap_next_entry(conn->ld, entry) != NULL) { - i_error("LDAP: Multiple replies found for user %s", - user.virtual_user); - } else { - urequest->userdb_callback(&user, request->context); - } + urequest->userdb_callback(&user, request->context); + t_pop(); + return; } + /* error */ + urequest->userdb_callback(NULL, request->context); t_pop(); }