You are here

function ldapdata_user_view in LDAP integration 5.2

Same name and namespace in other branches
  1. 5 ldapdata.module \ldapdata_user_view()
1 call to ldapdata_user_view()
ldapdata_user in ./ldapdata.module
Implements hook_user()

File

./ldapdata.module, line 690

Code

function ldapdata_user_view(&$user) {
  global $ldap, $ldap_attributes;
  if (!$user->ldap_authentified) {
    return;
  }
  $bind_info = _ldapdata_edition($user);
  if (!$ldap
    ->connect($bind_info[0], $bind_info[1])) {
    watchdog('user', "User view: user {$user->name}'s data could not be read in the LDAP directory", WATCHDOG_WARNING);
    return;
  }
  $entry = $ldap
    ->retrieveAttributes($user->ldap_dn);
  $ret = array();
  $allowed_attrs = _ldapdata_ldap_info($user, 'ldapdata_roattrs');
  foreach ($allowed_attrs as $attribute) {
    $item = array();
    $item['title'] = $ldap_attributes[$attribute][2];
    $item['value'] = theme('ldapdata_ldap_attribute', $entry[strtolower($attribute)][0], $ldap_attributes[$attribute][0]);
    $item['class'] = 'attribute';
    $ret[LDAP_SETTINGS_GROUP_STRING][] = $item;
  }
  $ldap
    ->disconnect();
  return $ret;
}