From 008af225edbe869973abffeed65c51bca6333505 Mon Sep 17 00:00:00 2001 From: hickert Date: Thu, 15 May 2008 13:19:38 +0000 Subject: [PATCH] Added new function which allows renaming of entries without creating copies and removing old entries. -Just added the function without any implementing it anywhere. git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@10918 594d385d-05f5-0310-b6e9-bd551577e9d8 --- gosa-core/include/class_ldap.inc | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/gosa-core/include/class_ldap.inc b/gosa-core/include/class_ldap.inc index bfd429c52..67921e0ba 100644 --- a/gosa-core/include/class_ldap.inc +++ b/gosa-core/include/class_ldap.inc @@ -443,6 +443,34 @@ class LDAP{ } } + + /*! \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) + { + /* Extract the name and the parent part out ouf source dn. + e.g. cn=herbert,ou=department,dc=... + parent => ou=department,dc=... + dest => cn=herbert + */ + $parent = preg_replace("/^[^,]+,/","",$dest); + $dest = preg_replace("/,.*$/","",$dest); + + if($this->hascon){ + if ($this->reconnect) $this->connect(); + $r= @ldap_rename($this->cid,$source,$dest,$parent,TRUE); + $this->error = @ldap_error($this->cid); + return(!$r ? $r : TRUE); + }else{ + $this->error = "Could not connect to LDAP server"; + return(FALSE); + } + } + + /** * Function rmdir_recursive * @@ -451,7 +479,6 @@ class LDAP{ * GiveBack: True on sucessfull , 0 in error, and "" when we don't get a ldap conection * */ - function rmdir_recursive($srp, $deletedn) { if($this->hascon){ -- 2.30.2