Author Topic: Pulling more fields from LDAP in SVN??  (Read 3438 times)

Offline ABerglund

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 673
Pulling more fields from LDAP in SVN??
« on: August 04, 2011, 07:24:59 PM »
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

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

Tried adding the fieldmappings as an array, as

Code: [Select]
 '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?
« Last Edit: August 05, 2011, 12:38:09 PM by ABerglund »
Arne Berglund
SysAdmin, Internet Services
Lane Education Service District
Eugene, OR, USA

Offline Julius Caesar

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 498
    • http://www.de-keizer.net/
Pulling more fields from LDAP in SVN??
« Reply #1 on: August 05, 2011, 03:44:05 AM »
Try to change it to:

Code: [Select]
 '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

Offline ABerglund

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 673
Pulling more fields from LDAP in SVN??
« Reply #2 on: August 05, 2011, 11:19:26 AM »
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:

Code: [Select]
$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
);
« Last Edit: August 05, 2011, 11:28:04 AM by ABerglund »
Arne Berglund
SysAdmin, Internet Services
Lane Education Service District
Eugene, OR, USA

Offline ABerglund

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 673
Pulling more fields from LDAP in SVN??
« Reply #3 on: August 08, 2011, 11:49:21 AM »
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".
« Last Edit: August 08, 2011, 12:01:38 PM by ABerglund »
Arne Berglund
SysAdmin, Internet Services
Lane Education Service District
Eugene, OR, USA

Offline ABerglund

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 673
Pulling more fields from LDAP in SVN??
« Reply #4 on: August 08, 2011, 12:28:23 PM »
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.

Code: [Select]
$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

Offline ABerglund

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 673
Pulling more fields from LDAP in SVN??
« Reply #5 on: August 08, 2011, 12:58:45 PM »
Quote from: ABerglund;36052
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?
[/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.
« Last Edit: August 08, 2011, 01:43:56 PM by ABerglund »
Arne Berglund
SysAdmin, Internet Services
Lane Education Service District
Eugene, OR, USA

Offline Julius Caesar

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 498
    • http://www.de-keizer.net/
Pulling more fields from LDAP in SVN??
« Reply #6 on: August 10, 2011, 03:04:29 AM »
Have you checked this thread for displaying (v5.x)
Julius Caesar

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