You are here

function writeAttributes in Lightweight Directory Access Protocol (LDAP) 6

File

includes/ldap.attribute.inc, line 132
Attribute Class and Manipulation Functions

Code

function writeAttributes($dn, $attributes) {
  foreach ($attributes as $key => $cur_val) {
    if ($cur_val == '') {
      unset($attributes[$key]);
      $old_value = $this
        ->retrieveAttribute($dn, $key);
      if (isset($old_value)) {
        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);
}