Hi,

I have the module working fine, and all the fields I want are displayed fine on the users respective profile pages. However, I have the need to use some of these values (such as cn, manager) in other areas of the site. I tried doing this;

$ldapdata_attributes = ldapdata_attributes();
print_r($ldapdata_attributes);

However, the printed array gives me nothing:
Array ( [givenName] => Array ( [0] => text [1] => textfield [2] => First Name [3] => 64 [4] => 64 ) [sn] => Array ( [0] => text [1] => textfield [2] => Last Name [3] => 64 [4] => 64 ) [cn] => Array ( [0] => text [1] => textfield [2] => Common Name [3] => 64 [4] => 64 ) [manager] => Array ( [0] => text [1] => textfield [2] => Manager [3] => 64 [4] => 64 ) [directreports] => Array ( [0] => text [1] => textfield [2] => Direct Reports [3] => 64 [4] => 64 ) [co] => Array ( [0] => text [1] => textfield [2] => Country [3] => 64 [4] => 64 ) [mail] => Array ( [0] => text [1] => textfield [2] => Email [3] => 64 [4] => 64 ) )

Does anyone know of a way to pull this information?

Thanks a lot for this module, and for any help!

Comments

tdobbs’s picture

Anyone have any ideas for this? I cant seem to find a way to pull this info.

tdobbs’s picture

For what its worth, the only way I could do this is add the values to the users profile using User Profiles and ldap_data. Then I had to get the data using

global $user;
profile_load_profile($user);

If anyone knows a way to grab these values without adding them to the profile let me know!

eikes’s picture

Here is what I came up with:

<?php
function MYMODULE_get_user_ldap_entry($user) {
  global $_ldapdata_ldap;
  $authmap = user_get_authmaps($user->name);
  if (!isset($authmap['ldapauth'])) {
    return false;
  }
  $bind_info = _ldapdata_edition($user);
  if (!$_ldapdata_ldap->connect($bind_info[0], $bind_info[1])) {
    watchdog('ldapdata', "User view: user %name's data could not be read in the LDAP directory", array('%name' => $user->name), WATCHDOG_WARNING);
    return false;
  }
  return $_ldapdata_ldap->retrieveAttributes($user->ldap_dn);
}
?>

It's just some code pulled from the ldap module. If it helps anyone...

cgmonroe’s picture

Status: Active » Closed (fixed)

Clearing out old support requests - reopen if problem still exists in newest code