summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 09a38ea)
raw | patch | inline | side by side (parent: 09a38ea)
author | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Thu, 6 Dec 2007 11:04:03 +0000 (11:04 +0000) | ||
committer | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Thu, 6 Dec 2007 11:04:03 +0000 (11:04 +0000) |
- Fixed the copy mehtod. Copies recursively now.
- The copy function should be rewritten, it seems to be a workarround..
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@8041 594d385d-05f5-0310-b6e9-bd551577e9d8
- The copy function should be rewritten, it seems to be a workarround..
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@8041 594d385d-05f5-0310-b6e9-bd551577e9d8
include/class_plugin.inc | patch | blob | history |
index 67c572bafb3520019c6e6fbe3bfa0391dc81aa45..f18d7e7311be3d5c122f8b0d3076399f4212a401 100644 (file)
--- a/include/class_plugin.inc
+++ b/include/class_plugin.inc
}
}
- /* This is a workaround function. */
- function copy($src_dn, $dst_dn)
- {
- /* Rename dn in possible object groups */
- $ldap= $this->config->get_ldap_link();
- $ldap->search('(&(objectClass=gosaGroupOfNames)(member='.@LDAP::fix($src_dn).'))',
- array('cn'));
- while ($attrs= $ldap->fetch()){
- $og= new ogroup($this->config, $ldap->getDN());
- unset($og->member[$src_dn]);
- $og->member[$dst_dn]= $dst_dn;
- $og->save ();
- }
-
- $ldap->cat($dst_dn);
- $attrs= $ldap->fetch();
- if (count($attrs)){
- trigger_error("Trying to overwrite ".@LDAP::fix($dst_dn).", which already exists.",
- E_USER_WARNING);
- return (FALSE);
- }
+ /* Recursively copy ldap object */
+ function _copy($src_dn,$dst_dn)
+ {
+ $ldap=$this->config->get_ldap_link();
$ldap->cat($src_dn);
$attrs= $ldap->fetch();
- if (!count($attrs)){
- trigger_error("Trying to move ".@LDAP::fix($src_dn).", which does not seem to exist.",
- E_USER_WARNING);
- return (FALSE);
- }
/* Grummble. This really sucks. PHP ldap doesn't support rdn stuff. */
$ds= ldap_connect($this->config->current['SERVER']);
E_USER_WARNING);
return(FALSE);
}
+ return(TRUE);
+ }
+
+ /* This is a workaround function. */
+ function copy($src_dn, $dst_dn)
+ {
+ /* Rename dn in possible object groups */
+ $ldap= $this->config->get_ldap_link();
+ $ldap->search('(&(objectClass=gosaGroupOfNames)(member='.@LDAP::fix($src_dn).'))',
+ array('cn'));
+ while ($attrs= $ldap->fetch()){
+ $og= new ogroup($this->config, $ldap->getDN());
+ unset($og->member[$src_dn]);
+ $og->member[$dst_dn]= $dst_dn;
+ $og->save ();
+ }
+
+ $ldap->cat($dst_dn);
+ $attrs= $ldap->fetch();
+ if (count($attrs)){
+ trigger_error("Trying to overwrite ".@LDAP::fix($dst_dn).", which already exists.",
+ E_USER_WARNING);
+ return (FALSE);
+ }
+
+ $ldap->cat($src_dn);
+ $attrs= $ldap->fetch();
+ if (!count($attrs)){
+ trigger_error("Trying to move ".@LDAP::fix($src_dn).", which does not seem to exist.",
+ E_USER_WARNING);
+ return (FALSE);
+ }
+
+ $ldap->cd($src_dn);
+ $ldap->search("objectClass=*",array("dn"));
+ while($attrs = $ldap->fetch()){
+ $src = $attrs['dn'];
+ $dst = preg_replace("/".normalizePreg($src_dn)."$/",$dst_dn,$attrs['dn']);
+ $this->_copy($src,$dst);
+ }
return (TRUE);
}
/* Delete source */
$ldap= $this->config->get_ldap_link();
- $ldap->rmdir($src_dn);
+ $ldap->rmdir_recursive($src_dn);
if ($ldap->error != "Success"){
trigger_error("Trying to delete $src_dn failed.",
E_USER_WARNING);