You are here

function ldapdata_user_view in LDAP integration 5

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

File

./ldapdata.module, line 688

Code

function ldapdata_user_view(&$user) {
  global $ldapdata_ldap, $ldap_attributes;
  if (!$user->ldap_authentified) {
    return;
  }
  $bind_info = _ldapdata_edition($user);
  if (!$ldapdata_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 = $ldapdata_ldap
    ->retrieveAttributes($user->ldap_dn);
  $ret = array();
  $allowed_attrs = _ldapdata_ldap_info($user, 'ldapdata_roattrs');
  if ($allowed_attrs) {
    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;
    }
  }
  $ldapdata_ldap
    ->disconnect();
  return $ret;
}