function ldapdata_user_form in LDAP integration 5.2
Same name and namespace in other branches
- 5 ldapdata.module \ldapdata_user_form()
Only used for editable LDAP attributes with no Drupal equivalents
1 call to ldapdata_user_form()
- ldapdata_user in ./
ldapdata.module - Implements hook_user()
File
- ./
ldapdata.module, line 424
Code
function ldapdata_user_form(&$user, $category) {
global $ldap_attributes, $ldap;
$mapping_type = _ldapdata_ldap_info($user, 'mapping_type');
$attributes = _ldapdata_ldap_info($user, 'ldapdata_rwattrs');
if (!$user->ldap_dn || $category != LDAP_CATEGORY_USER_DATA || $mapping_type != LDAP_MAP_ATTRIBUTES || !$attributes) {
return null;
}
$bind_info = _ldapdata_edition($user);
if (!$ldap
->connect($bind_info[0], $bind_info[1])) {
watchdog('user', "User form: user {$user->name}'s data could not be read in the LDAP directory", WATCHDOG_WARNING);
return;
}
$entry = $ldap
->retrieveAttributes($user->ldap_dn);
$output = '';
$form['ldap_attributes'] = array(
'#title' => LDAP_SETTINGS_GROUP_STRING,
'#type' => 'fieldset',
);
foreach ($attributes as $attribute) {
$attr_info = $ldap_attributes[$attribute];
if ($attr_info) {
array_shift($attr_info);
$value = $entry[strtolower($attribute)][0];
$form['ldap_attributes'][$attribute] = _ldapdata_attribute_form($attribute, $value, $attr_info);
}
}
$ldap
->disconnect();
return $form;
}