[RCD] Including department OU/information in LDAP searches

David Carter dpc22 at cam.ac.uk
Wed May 29 10:13:29 CEST 2013


I have been asked to add department names into the results generated by 
searches and autocompletion against our LDAP directory.

This solves problems with common names: I am one of at least four people 
named "David Carter" in the University.

The following hack solves our requirement: it generates results of the 
form "David Carter [University Computing Service] <dpc22 at cam.ac.uk>". The 
"[]" part gets stripped out by the onclick handler for autocompletion.

It is however playing games with strings passed from rcube_addressbook.php 
to app.js.src and relies on the fact that our directory never generates 
entries which contain '[' or ']' characters. The correct solution would be 
to pass objects around instead. If I had a go at the correct approach 
would there be any interest in merging the change upstream?

-- 
David Carter                             Email: David.Carter at ucs.cam.ac.uk
University Computing Service,            Phone: (01223) 334502
New Museums Site, Pembroke Street,       Fax:   (01223) 334679
Cambridge UK. CB2 3QH.

--- program/lib/Roundcube/BAK/rcube_addressbook.php	2013-05-15 13:08:25.000000000 +0100
+++ program/lib/Roundcube/rcube_addressbook.php	2013-05-17 12:19:17.000000000 +0100
@@ -509,6 +509,13 @@
          else
              $fn = !empty($contact['name']) ? $contact['name'] : join(' ', array($contact['prefix'], $contact['firstname'], $contact['middlename'], $contact['surname'], $contact['suffix']));

+        # DPC addition
+        if ($fn and $contact['department']) {
+            $depts = is_array($contact['department'])
+                ? join(', ', $contact['department']) : $contact['department'];
+            $fn = $fn . " [". $depts . "]";
+        }
+
          $fn = trim($fn, ', ');

          // fallback to display name

--- program/js/BAK/app.js.src	2013-05-15 20:31:27.000000000 +0100
+++ program/js/app.js.src	2013-05-17 12:19:05.000000000 +0100
@@ -3853,6 +3853,7 @@
      }
      else if (typeof this.env.contacts[id] === 'string') {
        insert = this.env.contacts[id] + this.env.recipients_delimiter;
+      insert=insert.replace(/ \[.+\]/, ""); // DPC
        trigger = true;
      }




More information about the dev mailing list