Hi Exim developers, I developed a small patch, which makes it possible to delegate the specification of LDAP servers and default search base to OpenLDAP's configuration mechanisms (ldap.conf, .ldaprc, environment variables).
The patch was developed by myself. I wanted to avoid to specify the LDAP servers and default search base twice. We have to provide these settings in /etc/ldap/ldap.conf anyway and so I thought, why not use OpenLDAP's auto-configuration in exim too. I used exim-4.69 (from Debian). As it is quiet small, it should be easy to apply for newer versions too. I cannot check these versions at the moment, so I did not test to apply it at all. Patch is attached and can also be found on http://www.mpi-inf.mpg.de/~pcernko/ldapdefaults.html . I would really like to see it integrated in any of the next versions. Feel free to change how to request default search base if you don't like the "default" string way I used. ;-) -- Patrick Cernko | mailto:[email protected]
diff -Naur exim4-4.69-orig/src/lookups/ldap.c exim4-4.69/src/lookups/ldap.c
--- exim4-4.69-orig/src/lookups/ldap.c 2007-01-08 11:50:19.000000000 +0100
+++ exim4-4.69/src/lookups/ldap.c 2010-05-28 14:56:54.000000000 +0200
@@ -349,8 +349,16 @@
/* Call ldap_initialize() and check the result */
- DEBUG(D_lookup) debug_printf("ldap_initialize with URL %s\n", init_url);
- rc = ldap_initialize(&ld, CS init_url);
+ /* Call ldap_initialize() and check the result */
+
+ if (!init_url ||
+ (Ustrcmp("ldap://:389/", init_url) == 0)) {
+ DEBUG(D_lookup) debug_printf("ldap_initialize using defaults\n");
+ rc = ldap_initialize(&ld, NULL);
+ } else {
+ DEBUG(D_lookup) debug_printf("ldap_initialize with URL %s\n", init_url);
+ rc = ldap_initialize(&ld, CS init_url);
+ }
if (rc != LDAP_SUCCESS)
{
*errmsg = string_sprintf("ldap_initialize: (error %d) URL \"%s\"\n",
@@ -567,10 +575,18 @@
/* Start the search on the server. */
+DEBUG(D_lookup) {
+ if (!ludp->lud_dn || (Ustrcmp("default", ludp->lud_dn) == 0)) {
+ debug_printf("using default ldap base from lib\n");
+ } else {
+ debug_printf("using default ldap base '%s'\n", ludp->lud_dn);
+ }
+}
DEBUG(D_lookup) debug_printf("Start search\n");
-msgid = ldap_search(lcp->ld, ludp->lud_dn, ludp->lud_scope, ludp->lud_filter,
- ludp->lud_attrs, 0);
+msgid = ldap_search(lcp->ld,
+ ((!ludp->lud_dn || (Ustrcmp("default", ludp->lud_dn) == 0)) ?
+ NULL : ludp->lud_dn), ludp->lud_scope, ludp->lud_filter, ludp->lud_attrs, 0);
if (msgid == -1)
{
smime.p7s
Description: S/MIME Cryptographic Signature
-- ## List details at http://lists.exim.org/mailman/listinfo/exim-dev Exim details at http://www.exim.org/ ##
