Roundcube Community Forum

 

Pulling more fields from LDAP in SVN??

Started by ABerglund, August 04, 2011, 07:24:59 PM

Previous topic - Next topic

ABerglund

Running a test server with a fresh (5025) SVN. Trying to get the global (read-only) LDAP addressbook to pull additional fields. Names and email still work as they do in my production 0.5.3. Adding a fieldmap of

'phone:work'  => 'telephonenumber',
does nothing. No phone shown, but everything else works as before.

Tried adding the fieldmappings as an array, as

 'fieldmap' => array(
    'name_field'    => 'cn',
    'email_field'   => 'mail',
    'surname_field' => 'sn',
    'firstname_field' => 'gn',
    'phone:work'  => 'telephonenumber',
    'organization' => 'o',
  ),

But that breaks the LDAP lookup. No records are shown, even though the ldap log file shows no errors.

Is the ability to display additional LDAP fields not implemented fully yet?
Arne Berglund
SysAdmin, Internet Services
Lane Education Service District
Eugene, OR, USA

Julius Caesar

Try to change it to:

 'fieldmap' => array(    'name_field'    => 'cn',
    'email_field'   => 'mail',
    'surname_field' => 'sn',
    'firstname_field' => 'gn',
    'phone:work_field'  => 'telephonenumber',
    'organization_field' => 'o',
  ),

Maybe the field 'phone:work' must be renamed to something without a colon, I.E. 'phone-work_field'
Julius Caesar

You can download the Groupvice4 theme here.
Sie können Groupvice4 hier he

ABerglund

#2
Thanks! Using 'phone:work_field' did the trick.

The sample code in main.inc.php.dist should be cleaned up at some point. It shows the 'phone:work' mapping, as well as showing all of the mappings inside a 'fieldmap' array. Using the array doesn't work at all, no records are displayed, even if you simply uncomment the sample Verisign lookup.

Here's an example of what works for me:

$rcmail_config['ldap_public']['LESD'] = array(
  'name'          => 'Lane ESD',
  'hosts'         => array('xxxx.lesd.k12.or.us'),
  'port'          => 389,
  'use_tls'       => false,
  'user_specific' => false,
  'base_dn'       => 'ou=People,dc=lesd,dc=k12,dc=or,dc=us',
  'ldap_version'  => 3,
  'search_fields' => array('mail', 'gn', 'sn'),
  'name_field'    => 'cn',
  'email_field'   => 'mail',
  'surname_field' => 'sn',
  'firstname_field' => 'gn',
  'phone:work_field'  => 'telephonenumber',
  'sort'          => 'sn',
  'scope'         => 'list',
  'filter'        => '',
  'fuzzy_search'  => true
);
Arne Berglund
SysAdmin, Internet Services
Lane Education Service District
Eugene, OR, USA

ABerglund

#3
OK, this works so well I'd like to expand it even further, and display other fields from LDAP as well. Is there a list of supported mappings somewhere? For example, I can pull the 'title', 'o', or 'ou' fields from LDAP correctly if I map them to one of the known-working mappings. But where are the supported mappings defined?

I'd especially like to map "Department" and "Job Title".
Arne Berglund
SysAdmin, Internet Services
Lane Education Service District
Eugene, OR, USA

ABerglund

Also, I have found that the problem when using a 'fieldmap' array is that if you define an array, the mappings must not include '_field". That format works for individual mappings, but not for a fieldmap array. So while the sample above works, this code here gives the same result. The comments inside rcube_ldap.php seem to indicate that the format I included above is deprecated, so this format is probably the preferred method.

$rcmail_config['ldap_public']['LESD'] = array(
  'name'          => 'Lane ESD',
  'hosts'         => array('xxxx.lesd.k12.or.us'),
  'port'          => 389,
  'use_tls'       => false,
  'user_specific' => false,
  'base_dn'       => 'ou=People,dc=lesd,dc=k12,dc=or,dc=us',
  'ldap_version'  => 3,
  'search_fields' => array('mail', 'gn', 'sn'),
  'fieldmap'      => array(
    'name'    => 'cn',
    'email'   => 'mail',
    'surname' => 'sn',
    'firstname' => 'gn',
    'phone:work'  => 'telephonenumber',
  ),
  'sort'          => 'sn',
  'scope'         => 'list',
  'filter'        => '',
  'fuzzy_search'  => true
);
Arne Berglund
SysAdmin, Internet Services
Lane Education Service District
Eugene, OR, USA

ABerglund

#5
Quote from: ABerglund;36052OK, this works so well I'd like to expand it even further, and display other fields from LDAP as well. Is there a list of supported mappings somewhere? For example, I can pull the 'title', 'o', or 'ou' fields from LDAP correctly if I map them to one of the known-working mappings. But where are the supported mappings defined?
[/FONT][/COLOR]Found the answer by looking through labels.inc. The correct fieldnames for these are:

    'jobtitle'    => 'title',
    'department'  => 'ou',
    'organization' => 'o',

I don't like how these fields are displayed (all in a single line without delimiters), but will enter a bug/feature request ticket on that.
Arne Berglund
SysAdmin, Internet Services
Lane Education Service District
Eugene, OR, USA

Julius Caesar

Julius Caesar

You can download the Groupvice4 theme here.
Sie können Groupvice4 hier he