[Exim] LDAP alias dereferencing (patch)

Startseite
Nachricht löschen
Nachricht beantworten
Autor: Christian Kellner
Datum:  
To: exim-users
Betreff: [Exim] LDAP alias dereferencing (patch)
Hi!

I lately switched from postfix to exim4. I am totally happy with it,
except for ldap alias dereferencing. I created a little patch and it
works really fine for me.

Use it like the size, time, user, pass, etc. by adding "dereference=X"
where x is either 0 (=none) [default],1 (=searching),2 (=finding), 3
(=always). I didn't use strings to avoid extra strncmpic function calls
but I could patch my patch (ok this sound rediciolous) to use symbolic
strings instead of integers if you wish.

-gicmo

P.S.: I am not in the list, so please cc me if you send any comments.
thanks.

----- snip -----

--- ldap_old.c    2003-08-18 23:33:36.000000000 +0200
+++ ldap.c    2003-08-18 23:33:08.000000000 +0200
@@ -80,6 +80,9 @@
 /* In all 4 cases, the DN is left in $ldap_dn (which post-dates the
 SEARCH_LDAP_DN lookup). */


+#ifndef LDAP_NO_DEREFERENCE
+#define LDAP_NO_DEREFERENCE 0
+#endif

/* Structure and anchor for caching connections. */

@@ -137,7 +140,7 @@
 static int
 perform_ldap_search(uschar *ldap_url, uschar *server, int s_port, int
search_type,
   uschar **res, uschar **errmsg, BOOL *defer_break, uschar *user,
uschar *password,
-  int sizelimit, int timelimit, int tcplimit)
+  int sizelimit, int timelimit, int tcplimit, int dereference)
 {
 LDAPURLDesc     *ludp = NULL;
 LDAPMessage     *result = NULL;
@@ -499,6 +502,10 @@
 lcp->ld->ld_timelimit = timelimit;
 #endif


+/* Set if we should dereference aliases */
+#if defined(LDAP_OPT_SIZELIMIT)
+ldap_set_option(lcp->ld, LDAP_OPT_DEREF, (void *)&dereference);
+#endif
/* Start the search on the server. */

 DEBUG(D_lookup) debug_printf("Start search\n");
@@ -884,6 +891,7 @@
 int timelimit = LDAP_NO_LIMIT;
 int sizelimit = LDAP_NO_LIMIT;
 int tcplimit = LDAP_X_IO_TIMEOUT_NO_TIMEOUT;
+int dereference = LDAP_NO_DEREFERENCE;
 int sep = 0;
 uschar *url = ldap_url;
 uschar *p;
@@ -916,6 +924,7 @@
       else if (strncmpic(name, US"SIZE=", namelen) == 0) sizelimit =
Uatoi(value);
       else if (strncmpic(name, US"TIME=", namelen) == 0) timelimit =
Uatoi(value);
       else if (strncmpic(name, US"CONNECT=", namelen) == 0) tcplimit =
Uatoi(value) * 1000;
+      else if (strncmpic(name, US"DEREFERENCE=", namelen) == 0)
dereference = Uatoi(value);
       else
         {
         *errmsg =
@@ -999,7 +1008,7 @@
 if (eldap_default_servers == NULL || p[3] != '/')
   {
   return perform_ldap_search(url, NULL, 0, search_type, res, errmsg,
-    &defer_break, user, password, sizelimit, timelimit, tcplimit);
+    &defer_break, user, password, sizelimit, timelimit, tcplimit,
dereference);
   }


 /* Loop through the default servers until OK or FAIL */
@@ -1016,7 +1025,7 @@
     port = Uatoi(colon+1);
     }
   rc = perform_ldap_search(url, server, port, search_type, res, errmsg,
-    &defer_break, user, password, sizelimit, timelimit, tcplimit);
+    &defer_break, user, password, sizelimit, timelimit, tcplimit,
dereference);
   if (rc != DEFER || defer_break) return rc;
   }


---- snap ----