Code

Added new function which allows renaming of entries without creating copies and remov...
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 15 May 2008 13:19:38 +0000 (13:19 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 15 May 2008 13:19:38 +0000 (13:19 +0000)
-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

index bfd429c529920d3c7fa9f55978a2682ea5446a20..67921e0ba5565eb140520d50b3ee40baabe44f50 100644 (file)
@@ -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){