Index: /branches/devel-addressbook/config/main.inc.php.dist
===================================================================
--- /branches/devel-addressbook/config/main.inc.php.dist	(revision 4340)
+++ /branches/devel-addressbook/config/main.inc.php.dist	(revision 4341)
@@ -449,5 +449,4 @@
   'search_base_dn' => '',
   'search_filter'  => '',   // e.g. '(&(objectClass=posixAccount)(uid=%u))'
-
   'writable'      => false,   // Indicates if we can write to the LDAP directory or not.
   // If writable is true then these fields need to be populated:
@@ -458,8 +457,17 @@
   'ldap_version'  => 3,       // using LDAPv3
   'search_fields' => array('mail', 'cn'),  // fields to search in
-  'name_field'    => 'cn',    // this field represents the contact's name
-  'email_field'   => 'mail',  // this field represents the contact's e-mail
-  'surname_field' => 'sn',    // this field represents the contact's last name
-  'firstname_field' => 'gn',  // this field represents the contact's first name
+  'fieldmap' => array(      // mapping of contact fields to directory attributes
+    // roundcube  => ldap
+    'name'        => 'cn',
+    'surname'     => 'sn',
+    'firstname'   => 'givenName',
+    'phone'       => 'telephoneNumber',
+    'email'       => 'mail',
+    'street'      => 'street',
+    'zipcode'     => 'postalCode',
+    'locality'    => 'l',
+    'country'     => 'c',
+    'organization' => 'o',
+  ),
   'sort'          => 'cn',    // The field to sort the listing by.
   'scope'         => 'sub',   // search mode: sub|base|list
Index: /branches/devel-addressbook/program/include/rcube_ldap.php
===================================================================
--- /branches/devel-addressbook/program/include/rcube_ldap.php	(revision 4340)
+++ /branches/devel-addressbook/program/include/rcube_ldap.php	(revision 4341)
@@ -58,7 +58,20 @@
     $this->prop = $p;
 
-    foreach ($p as $prop => $value)
-      if (preg_match('/^(.+)_field$/', $prop, $matches))
-        $this->fieldmap[$matches[1]] = $this->_attr_name(strtolower($value));
+    // fieldmap property is given
+    if (is_array($p['fieldmap'])) {
+      foreach ($p['fieldmap'] as $rf => $lf)
+          $this->fieldmap[$rf] = $this->_attr_name(strtolower($lf));
+    }
+    else {
+      // read deprecated *_field properties to remain backwards compatible
+      foreach ($p as $prop => $value)
+        if (preg_match('/^(.+)_field$/', $prop, $matches))
+          $this->fieldmap[$matches[1]] = $this->_attr_name(strtolower($value));
+    }
+    
+    // use fieldmap to advertise supported coltypes to the application
+    $this->coltypes = array_keys($this->fieldmap);
+    if ($this->fieldmap['street'] && $this->fieldmap['locality'])
+      $this->coltypes[] = 'address';
 
     // make sure 'required_fields' is an array
@@ -680,6 +693,4 @@
   private function _ldap2result($rec)
   {
-    global $RCMAIL;
-
     $out = array();
     
@@ -689,9 +700,15 @@
     foreach ($this->fieldmap as $rf => $lf)
     {
-      if ($rec[$lf]['count']) {
-        if ($rf == 'email' && $this->mail_domain && !strpos($rec[$lf][0], '@'))
-          $out[$rf] = sprintf('%s@%s', $rec[$lf][0], $this->mail_domain);
+      for ($i=0; $i < $rec[$lf]['count']; $i++) {
+        if (!($value = $rec[$lf][$i]))
+          continue;
+        if ($rf == 'email' && $this->mail_domain && !strpos($value, '@'))
+          $out[$rf][] = sprintf('%s@%s', $value, $this->mail_domain);
+        else if (in_array($rf, array('street','zipcode','locality','country','region')))
+          $out['address'][$i][$rf] = $value;
+        else if ($rec[$lf]['count'] > 1)
+          $out[$rf][] = $value;
         else
-          $out[$rf] = $rec[$lf][0];
+          $out[$rf] = $value;
       }
     }
