index bfd429c529920d3c7fa9f55978a2682ea5446a20..2bbb1d875ee9a5365f04a675af57c5ed22f27b1e 100644 (file)
}
}
+
+ /*! \brief Move the given Ldap entry from $source to $dest
+ @param String $source The source dn.
+ @param String $dest The destination dn.
+ @return Boolean TRUE on success else FALSE.
+ */
+ function rename_dn($source,$dest)
+ {
+ /* Check if source and destination are the same entry */
+ if(strtolower($source) == strtolower($dest)){
+ trigger_error("Source and destination can't be the same entry.");
+ return(FALSE);
+ }
+
+ /* Check if destination entry exists */
+ if($this->dn_exists($dest)){
+ trigger_error("Destination '$dest' already exists.");
+ return(FALSE);
+ }
+
+ /* Extract the name and the parent part out ouf source dn.
+ e.g. cn=herbert,ou=department,dc=...
+ parent => ou=department,dc=...
+ dest_rdn => cn=herbert
+ */
+ $parent = preg_replace("/^[^,]+,/","",$dest);
+ $dest_rdn = preg_replace("/,.*$/","",$dest);
+
+ if($this->hascon){
+ if ($this->reconnect) $this->connect();
+ $r= @ldap_rename($this->cid,$source,$dest_rdn,$parent,TRUE);
+ $this->error = @ldap_error($this->cid);
+
+ /* Check if destination dn exists, if not the
+ server may not support this operation */
+ $r &= $this->dn_exists($dest);
+ return(!$r ? $r : TRUE);
+ }else{
+ $this->error = "Could not connect to LDAP server";
+ return(FALSE);
+ }
+ }
+
+
/**
* Function rmdir_recursive
*
* GiveBack: True on sucessfull , 0 in error, and "" when we don't get a ldap conection
*
*/
-
function rmdir_recursive($srp, $deletedn)
{
if($this->hascon){