[turba] FW: LDAP composed primary key...

Chuck Hagenbuch chuck at horde.org
Fri Oct 17 13:33:12 PDT 2003


>From a generous man.

----- Forwarded message from zakmck at iol.it -----
    Date: Fri, 17 Oct 2003 00:30:59 +0000
    From: Zak Mc Kracken <zakmck at iol.it>
Reply-To: Zak Mc Kracken <zakmck at iol.it>
 Subject: FW: LDAP composed primary key...
      To: turba-owner at lists.horde.org

Dear TURBA/ADMIN,

I do think it's really stupid forbidding a post to a public, probably
moderated, mailing list just because I'm not subscribed.

I don't have time to waste in subscribing myself, sending a possible
contribute, unsubscribe sudden after.

Please find attached the contribute I have attempted tu submit, free to
publish in case you find it interesting.

Greetings

Marco Brandizi <zakmck at NOSPAMiol.it>






You are not allowed to post to this mailing list, and your message has
been automatically rejected.  If you think that your messages are
being rejected in error, contact the mailing list owner at
turba-owner at lists.horde.org.



Subject:
LDAP composed primary key...
From:
Zak Mc Kracken <zakmck at iol.it>
Date:
Wed, 15 Oct 2003 01:35:07 +0000
To:
turba at lists.horde.org

Hi all
I'm importing, via Turba / CSV import, in LDAP a long address list.
Since practically I don't have a primary key (all the fields are part of
key, there are almost identical rows and I don't have time to check 1000
entries), I would like to use this as primary:

                   // Generates MD5 unique ID from record
                   $attrs = '';
                   foreach ( $attributes as $attr ) {
                     if ( $attrs ) $attrs .= '';
                     $attrs .= $attr;
                   }
                   $dn .= 'uid=' . md5 ( $attrs ) . ',';


i.e.: the primary key is an hash of the entire row.

But unfortunately Turba expects a list of attributes as key
specification, so that I've hacked lib/driver/ldap.php, in the following
way:

     function makeKey($attributes)
     {
         $dn = '';
         if (is_array($this->_params['dn'])) {
             foreach ($this->_params['dn'] as $param) {
/* Marco Brandizi, Oct 2003, A VERY dirty trick to support dn dynamic */
               if ( $param == 'uid' )
               {
                   // Generates MD5 unique ID from record
                   $attrs = '';
                   foreach ( $attributes as $attr ) {
                     if ( $attrs ) $attrs .= '';
                     $attrs .= $attr;
                   }
                   $dn .= 'uid=' . md5 ( $attrs ) . ',';

               }
               else
// End of Brandizi Trick
                   if (isset($attributes[$param])) {
                     $dn .= $param . '=' . $attributes[$param] . ',';
                   }
             }
         }

         $dn .= $this->_params['root'];
         return $dn;
     }



Is there a cleaner way to do what I want? For example telling Turba it
should pass a parameter to eval()? It would be nice even something less
than I'm doing, for example the simple ability to specify the key is the
concatenation of several attributes.

NOTE: About this latter point, I cannot write (in config/sources.php)
...
         'dn' => array( 'cn', 'sn' ),
...

Since the result would be "dn=cn=Marco,sn=Brandizi..." and with this
search string LDAP expects to find an object.






----- End forwarded message -----


-chuck

--
Charles Hagenbuch, <chuck at horde.org>
Born right the first time.


More information about the turba mailing list