public function SimpleLdapServer::move in Simple LDAP 7.2
Same name and namespace in other branches
- 7 SimpleLdapServer.class.php \SimpleLdapServer::move()
Move an entry to a new DN.
@throw SimpleLdapException
Parameters
string $dn: The distinguished name of an LDAP entry.
string $newdn: The new distinguished name of the LDAP entry.
boolean $deleteoldrdn: If TRUE the old RDN value(s) is removed, else the old RDN value(s) is retained as non-distinguished values of the entry.
Return value
boolean TRUE on success
File
- ./
SimpleLdapServer.class.php, line 603 - Class to handle LDAP server connections and related operations.
Class
- SimpleLdapServer
- Simple LDAP server class.
Code
public function move($dn, $newdn, $deleteoldrdn = TRUE) {
// Make sure changes are allowed.
if ($this->readonly) {
throw new SimpleLdapException('The LDAP Server is configured as read-only');
}
// Make sure there is a valid binding.
$this
->bind();
// Parse $newdn into a format that ldap_rename() can use.
$parts = SimpleLdap::ldap_explode_dn($newdn, 0);
$rdn = $parts[0];
$parent = '';
for ($i = 1; $i < $parts['count']; $i++) {
$parent .= $parts[$i];
if ($i < $parts['count'] - 1) {
$parent .= ',';
}
}
// Move the entry.
return SimpleLdap::ldap_rename($this->resource, $dn, $rdn, $parent, $deleteoldrdn);
}