You are here

function LDAPInterface::writeAttributes in LDAP integration 5.2

Same name and namespace in other branches
  1. 5 ldap_integration/LDAPInterface.php \LDAPInterface::writeAttributes()
  2. 6 includes/LDAPInterface.inc \LDAPInterface::writeAttributes()

File

ldap_integration/LDAPInterface.php, line 217

Class

LDAPInterface

Code

function writeAttributes($dn, $attributes) {
  foreach ($attributes as $key => $cur_val) {
    if ($cur_val == '') {
      unset($attributes[$key]);
      $old_value = $this
        ->retrieveAttribute($dn, $key);
      ldap_mod_del($this->connection, $dn, array(
        $key => $old_value,
      ));
    }
    if (is_array($cur_val)) {
      foreach ($cur_val as $mv_key => $mv_cur_val) {
        if ($mv_cur_val == '') {
          unset($attributes[$key][$mv_key]);
        }
        else {
          $attributes[$key][$mv_key] = $mv_cur_val;
        }
      }
    }
  }
  ldap_modify($this->connection, $dn, $attributes);
}