changeset 1910:b9005f93be70 HEAD

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.
author Timo Sirainen <tss@iki.fi>
date Mon, 26 Apr 2004 01:40:29 +0300
parents a3a6b702c766
children ac810e95cdd6
files src/auth/db-ldap.c src/auth/db-ldap.h
diffstat 2 files changed, 10 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/auth/db-ldap.c	Mon Apr 26 01:30:25 2004 +0300
+++ b/src/auth/db-ldap.c	Mon Apr 26 01:40:29 2004 +0300
@@ -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 @@
 };
 
 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 @@
 		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);
--- a/src/auth/db-ldap.h	Mon Apr 26 01:30:25 2004 +0300
+++ b/src/auth/db-ldap.h	Mon Apr 26 01:40:29 2004 +0300
@@ -12,6 +12,7 @@
 
 struct ldap_settings {
 	const char *hosts;
+	const char *uris;
 	const char *dn;
 	const char *dnpass;
 	const char *deref;