SVN Releases > SVN Discussion

Pulling more fields from LDAP in SVN??

(1/2) > >>

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


--- Code: ---'phone:work'  => 'telephonenumber',
--- End code ---

does nothing. No phone shown, but everything else works as before.

Tried adding the fieldmappings as an array, as


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

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?

Julius Caesar:
Try to change it to:


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

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

ABerglund:
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: ---$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
);

--- End code ---

ABerglund:
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".

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.


--- Code: ---$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
);
--- End code ---

Navigation

[0] Message Index

[#] Next page

Go to full version