/** * Deletes values of current attribute given in arguments. * * This method takes a variable number of arguments each representing * existing value of current attribute to be deleted/removed. Since empty * strings are ignored, there may be no value to delete. In that case * no values are deleted at all. * * @throws protocol_exception * @param string $firstValueToDelete first value of attribute to delete * @return attribute current instance */ public function delete($firstValueToDelete) { if (!$this->faking) { $values = array_filter(array_map(function ($a) { return trim($a); }, func_get_args()), function ($a) { return $a !== ''; }); if (count($values)) { if ($this->node->isAdjusting()) { $this->node->adjust($this, array_diff($this->read(), $values)); } else { if (!@ldap_mod_del($this->node->getLink(), $this->node->getDN(), array($this->name => $values))) { throw new protocol_exception(sprintf('failed to delete values of attribute %s', $this->name), $this->node->getLink(), $this->node->getDN()); } } } } return $this; }
/** * Moves/renames current node/entry. * * If $newParent is given this entry/node is moved in LDAP tree to its new * position. * * @example * * DN of entry: cn=John Doe,ou=people,dc=example,dc=com * RDN of same entry: cn=John Doe * * @throws protocol_exception * @param string $newRDN relative DN of current entry * @param node $newParent node entry entry is subordinated to on moving, omit to rename locally * @param boolean $keepPreviousRDN true to keep previous RDN as "normal" attribute * @return node current instance */ public function move($newRDN, node $newParent = null, $keepPreviousRDN = true) { if ($this->isAdjusting()) { throw new protocol_exception('must not move while adjusting entry', $this->link, $this->getDN()); } if ($newParent) { $superRDN = $newParent->getDN(); } else { $superRDN = trim(preg_replace('/^[^,]+,/', '', $this->getDN())); } if (!@ldap_rename($this->link, $this->getDN(), $newRDN, $superRDN, !!$keepPreviousRDN)) { throw new protocol_exception('failed to move entry', $this->link, $this->getDN()); } return $this; }