strip basedn from nickname.
authortokul <tokul@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Mon, 1 Aug 2005 08:07:13 +0000 (08:07 +0000)
committertokul <tokul@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Mon, 1 Aug 2005 08:07:13 +0000 (08:07 +0000)
git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@9861 7612ce4b-ef26-0410-bec9-ea0150e637f0

functions/abook_ldap_server.php

index 72b941016eae8e583a92debe7c82292f5d37681f..596360a6275a3ad250182771183eac7712bfc11c 100644 (file)
@@ -389,9 +389,16 @@ class abook_ldap_server extends addressbook_backend {
             $row = $res[$i];
 
             /* Extract data common for all e-mail addresses
-             * of an object. Use only the first name */
+             * of an object. Use only the first name */      
             $nickname = $this->charset_decode($row['dn']);
-            // TODO: remove basedn from $nickname
+
+            /**
+             * calculate length of basedn and remove it from nickname
+             * ignore whitespaces between RDNs
+             * Nicknames are shorter and still unique
+             */ 
+            $basedn_len=strlen(preg_replace('/,\s*/',',',trim($this->basedn)));
+            $nickname=substr(preg_replace('/,\s*/',',',$nickname),0,(-1 - $basedn_len));
 
             $fullname = $this->charset_decode($row['cn'][0]);