diff --git a/include/class_ldap.inc b/include/class_ldap.inc
index 1570b8aab6ad2cd2bcb68dce134a6855128a17cd..96ff38e203b08e796d2a663a796ef53dd8e9d190 100644 (file)
--- a/include/class_ldap.inc
+++ b/include/class_ldap.inc
}
}
- function cat($dn)
+ function cat($dn,$attrs= array("*"))
{
if($this->hascon){
if ($this->reconnect) $this->connect();
$this->clearResult();
$filter = "(objectclass=*)";
- $this->sr = @ldap_read($this->cid, $this->fix($dn), $filter);
+ $this->sr = @ldap_read($this->cid, $this->fix($dn), $filter,$attrs);
$this->error = @ldap_error($this->cid);
$this->resetResult();
$this->hasres=true;
}
/* Copy given attributes and sub-dns with attributes to destination dn
-
*/
- function copy_FAI_resource_recursive($sourcedn,$destinationdn,$type="branch",$is_first = false)
+ function copy_FAI_resource_recursive($sourcedn,$destinationdn,$type="branch",$is_first = true,$depth=0)
{
error_reporting(E_ALL);
+
+ if($is_first){
+ echo "<h2>".sprintf(_("Creating copy of %s"),"<i>".$sourcedn."</i>")."</h2>";
+ }else{
+ if(preg_match("/^ou=/",$sourcedn)){
+ echo "<h3>"._("Processing")." <i>$destinationdn</i></h3>";
+ }else{
+ $tmp = split(",",$sourcedn);
+
+ echo " <b>"._("Object").":</b> ";
+
+ $deststr = $destinationdn;
+ if(strlen($deststr) > 96){
+ $deststr = substr($deststr,0,96)."...";
+ }
+
+ echo $deststr."<br>";
+ }
+ }
+
+ flush();
+
if($this->hascon){
if ($this->reconnect) $this->connect();
/* Save base dn */
$basedn= $this->basedn;
$delarray= array();
-
+
/* Check if destination entry already exists */
- if($this->count($this->fetch($this->cat($destinationdn)))){
+ $this->cat($destinationdn);
+
+ if($this->count()){
return;
}else{
+
+ $this->clearResult();
- /* Get source entrie */
+ /* Get source entry */
$this->cd($basedn);
- $attr = $this->fetch($this->cat($sourcedn));
+ $this->cat($sourcedn);
+ $attr = $this->fetch();
+ /* Error while fetching object / attribute abort*/
+ if((!$attr) || (count($attr)) ==0) {
+ echo _("Error while fetching source dn - aborted!");
+ return;
+ }
+
/* check if this is a department */
if(in_array("organizationalUnit",$attr['objectClass'])){
$attr['dn'] = $this->convert($destinationdn);
/* If is first entry, append FAIbranch to department entry */
if($is_first){
- $attr= $this->fetch($this->cat($destinationdn));
+ $this->cat($destinationdn);
+ $attr= $this->fetch();
/* Filter unneeded informations */
foreach($attr as $key => $value){
/* Add this entry */
$this->modify($attr);
}
-
}else{
- /* If this is no department */
- foreach($attr as $key => $value){
- if(in_array($key ,array("FAItemplateFile","FAIscript"))){
- $sr= ldap_read($this->cid, $this->fix($sourcedn), "(objectClass=FAIclass)", array($key));
+ /* If this is no department */
+ foreach($attr as $key => $value){
+ if(in_array($key ,array("FAItemplateFile","FAIscript", "gotoLogonScript", "gosaApplicationIcon"))){
+ $sr= ldap_read($this->cid, $this->fix($sourcedn), "$key=*", array($key));
$ei= ldap_first_entry($this->cid, $sr);
- $tmp = (@ldap_get_values_len($this->cid, $ei,$key));
- if(is_array($tmp)){
+ if ($tmp= @ldap_get_values_len($this->cid, $ei,$key)){
$attr[$key] = $tmp;
}
}
unset($attr['count']);
unset($attr['dn']);
-
- if($type=="branch"){
- $attr['FAIstate'] ="branch";
- }elseif($type=="freeze"){
- $attr['FAIstate'] ="freeze";
- }else{
- print_red(_("Unknown FAIstate %s"),$type);
+ if(!in_array("gosaApplication" , $attr['objectClass'])){
+ if($type=="branch"){
+ $attr['FAIstate'] ="branch";
+ }elseif($type=="freeze"){
+ $attr['FAIstate'] ="freeze";
+ }else{
+ print_red(_("Unknown FAIstate %s"),$type);
+ }
}
-
+
/* Add entry */
$this->cd($destinationdn);
- $a = $this->fetch($this->cat($destinationdn));
+ $this->cat($destinationdn);
+ $a = $this->fetch();
if(!count($a)){
$this->add($attr);
}
asort ($delarray);
reset ($delarray);
+ $depth ++;
foreach($delarray as $dn => $bla){
if($dn != $destinationdn){
$this->cd($basedn);
$item = $this->fetch($this->cat($dn));
if(!in_array("FAIbranch",$item['objectClass'])){
- $this->copy_FAI_resource_recursive($dn,str_replace($sourcedn,$destinationdn,$dn),$type);
+ $this->copy_FAI_resource_recursive($dn,str_replace($sourcedn,$destinationdn,$dn),$type,false,$depth);
}
}
}
}
+ if($is_first){
+ echo "<p class='seperator'> </p>";
+ }
+
}
function modify($attrs)