You are here

function _ldapdata_user_update_ldap_attributes in LDAP integration 6

Find out which LDAP attributes should be synced back to LDAP..

Parameters

$edit: A submitted form data.

$user: A user object.

Return value

An associated array of attributes to write to LDAP.

1 call to _ldapdata_user_update_ldap_attributes()
_ldapdata_user_submit in ./ldapdata.module
Implements hook_user() submit operation.

File

./ldapdata.module, line 558
ldapdata provides data maping against ldap server.

Code

function _ldapdata_user_update_ldap_attributes(&$edit, &$user) {
  $writeout = array();
  $editables = _ldapdata_ldap_info($user, 'ldapdata_rwattrs');
  foreach ($edit as $edit_attr => $value) {

    // Preventing a POST data injection: we check allowance to write value.
    if (($ldap_attr = preg_replace('/^ldap_(.*)$/', '$1', $edit_attr)) && in_array($ldap_attr, $editables)) {
      $writeout[$ldap_attr] = $value;
    }
    unset($edit[$edit_attr]);
  }
  return $writeout;
}