From e65cc79f80577e83c706f0678c78e2c0bd91434f Mon Sep 17 00:00:00 2001 From: Timo Sirainen Date: Mon, 26 Apr 2004 01:40:29 +0300 Subject: [PATCH] Patch by Quentin Garnier: 1. Change default value for 'hosts' to NULL instead of 'localhost'. That way, libldap will choose the default list of server as specified in OpenLDAP's ldap.conf configuration file. 2. Add a new configuration stance, 'uris', which you can set to a list of URIs that will be passed directly to libldap, which understands them. --HG-- branch : HEAD --- src/auth/db-ldap.c | 11 +++++++++-- src/auth/db-ldap.h | 1 + 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/auth/db-ldap.c b/src/auth/db-ldap.c index 14d13b514e..f4fbdbd348 100644 --- a/src/auth/db-ldap.c +++ b/src/auth/db-ldap.c @@ -26,6 +26,7 @@ static struct setting_def setting_defs[] = { DEF(SET_STR, hosts), + DEF(SET_STR, uris), DEF(SET_STR, dn), DEF(SET_STR, dnpass), DEF(SET_STR, deref), @@ -42,7 +43,8 @@ static struct setting_def setting_defs[] = { }; struct ldap_settings default_ldap_settings = { - MEMBER(hosts) "localhost", + MEMBER(hosts) NULL, + MEMBER(uris) NULL, MEMBER(dn) NULL, MEMBER(dnpass) NULL, MEMBER(deref) "never", @@ -178,7 +180,12 @@ static int ldap_conn_open(struct ldap_connection *conn) return TRUE; if (conn->ld == NULL) { - conn->ld = ldap_init(conn->set.hosts, LDAP_PORT); + if (conn->set.uris != NULL) { + if (ldap_initialize(&conn->ld, conn->set.uris) != LDAP_SUCCESS) + conn->ld = NULL; + } else + conn->ld = ldap_init(conn->set.hosts, LDAP_PORT); + if (conn->ld == NULL) i_fatal("LDAP: ldap_init() failed with hosts: %s", conn->set.hosts); diff --git a/src/auth/db-ldap.h b/src/auth/db-ldap.h index 21ae5a82da..17d87bf7fc 100644 --- a/src/auth/db-ldap.h +++ b/src/auth/db-ldap.h @@ -12,6 +12,7 @@ typedef void db_search_callback_t(struct ldap_connection *conn, struct ldap_settings { const char *hosts; + const char *uris; const char *dn; const char *dnpass; const char *deref; -- 2.47.3