Re: [exim] missing comma in ldap replies

Αρχική Σελίδα
Delete this message
Reply to this message
Συντάκτης: Heiko Schlittermann
Ημερομηνία:  
Προς: Jeremy Harris
Υ/ο: exim-users
Αντικείμενο: Re: [exim] missing comma in ldap replies
Hello,

Jeremy Harris <jgh@???> (Mi 27 Aug 2014 19:33:18 CEST):

> > attributetype (
> >     eximAttribute:1 NAME ('x-MailPrimaryAddress' 'x-MailAddress' 'x-MailOfficialAddress') 
> >     DESC 'official mail address'
> >     SINGLE-VALUE
> >     SUP mail )

> >
> > attributetype (
> >     eximAttribute:2 NAME ('x-MailAlternateAddress' 'x-MailAlias') 
> >     DESC 'alternate mail address (alias)'
> >     SUP mail )

>
> You may be able to tell I don't really talk LDAP :)
>
> What do we want the Exim expansion's view of the results to be?
> Labelled by the base object class, or by the text
> "x-MailAlternateAddress" (or whchever)?


I'd say, by the name of the attribute.

> diff --git a/src/src/lookups/ldap.c b/src/src/lookups/ldap.c
> index f77229d..64af12d 100644



Here comes a shorter patch. I'll test yours too.

diff --git a/src/src/lookups/ldap.c b/src/src/lookups/ldap.c
index f77229d..ef7ed9e 100644
--- a/src/src/lookups/ldap.c
+++ b/src/src/lookups/ldap.c
@@ -797,7 +797,13 @@ while ((rc = ldap_result(lcp->ld, msgid, 0, timeoutptr, &result)) ==

             DEBUG(D_lookup) debug_printf("LDAP attr loop %s:%s\n", attr, value);


-            if (values != firstval)
+        /* In case we requested one attribute only but got
+         * several times into that attr loop, we need to append
+         * the additional values. (This may happen if you derive 
+         * attributeTypes B and C from A and then query for A.)
+         * In all other cases we detect the different attribute
+         * and append only every non first value. */
+        if ((attr_count == 1 && data) || (values != firstval))
               data = string_cat(data, &size, &ptr, US",", 1);


             /* For multiple attributes, the data is in quotes. We must escape


For testing I'm using the following LDAP entry:

    dn: uid=heiko,dc=schlittermann,dc=de
    x-MailPrimaryAddress: hs@???
    description: a
    description: b,c
    x-MailAlternateAddress: h,e@???
    x-MailAlternateAddress: heiko@???
    x-MailAlternateAddress: heiko@???


$ ../../build-Linux-x86_64/exim -be '${lookup ldap{ldap:///dc=schlittermann,dc=de?mail?sub?uid=heiko}}'
hs@???,h,,e@???,heiko@???,heiko@???

$ ../../build-Linux-x86_64/exim -be '${lookup ldap{ldap:///dc=schlittermann,dc=de?description,mail?sub?uid=heiko}}'
x-MailPrimaryAddress="hs@???" description="a,b,,c" x-MailAlternateAddress="h,,e@???,heiko@???,heiko@???"


But, I'm not sure if I didn't break anything else :)


    Best regards from Dresden/Germany
    Viele Grüße aus Dresden
    Heiko Schlittermann
-- 
 SCHLITTERMANN.de ---------------------------- internet & unix support -
 Heiko Schlittermann, Dipl.-Ing. (TU) - {fon,fax}: +49.351.802998{1,3} -
 gnupg encrypted messages are welcome --------------- key ID: 7CBF764A -
 gnupg fingerprint: 9288 F17D BBF9 9625 5ABC  285C 26A9 687E 7CBF 764A -
(gnupg fingerprint: 3061 CFBF 2D88 F034 E8D2  7E92 EE4E AC98 48D0 359B)-