summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: c0c66ae)
raw | patch | inline | side by side (parent: c0c66ae)
author | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Fri, 14 May 2010 09:27:07 +0000 (09:27 +0000) | ||
committer | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Fri, 14 May 2010 09:27:07 +0000 (09:27 +0000) |
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@18472 594d385d-05f5-0310-b6e9-bd551577e9d8
gosa-plugins/fai/admin/fai/class_FAI.inc | patch | blob | history | |
gosa-plugins/fai/admin/fai/migration/class_migrateFaiRDN.inc | patch | blob | history |
index 6bb494aec212382a0431c06d2d5bd939b52162f0..e23adcb7aa4c34c24d35691a2c7cde292348289f 100644 (file)
/* Return all relevant FAI departments */
static function get_FAI_departments($suffix = "")
{
- $arr = array("hooks","scripts","disk","packages","profiles","templates","variables");
+ global $config;
+ $arr = array(
+ $config->get_cfg_value('faiScript', 'faiScriptRDN'),
+ $config->get_cfg_value('faiHook', 'faiHookRDN'),
+ $config->get_cfg_value('faiTemplate', 'faiTemplateRDN'),
+ $config->get_cfg_value('faiVariable', 'faiVariableRDN'),
+ $config->get_cfg_value('faiProfile', 'faiProfileRDN'),
+ $config->get_cfg_value('faiPartitionTable', 'faiPartitionRDN'),
+ $config->get_cfg_value('faiPackage', 'faiPackageRDN')
+ );
+
$tmp = array();
if(preg_match("/^,/",$suffix)){
$suffix = preg_replace("/^,/","",$suffix);
}
foreach($arr as $name){
if(empty($suffix)){
- $tmp[$name] = "ou=".$name;
+ $tmp[$name] = $name;
}else{
- $tmp[$name] = "ou=".$name.",".$suffix;
+ $tmp[$name] = $name.$suffix;
}
}
return($tmp);
diff --git a/gosa-plugins/fai/admin/fai/migration/class_migrateFaiRDN.inc b/gosa-plugins/fai/admin/fai/migration/class_migrateFaiRDN.inc
index b832513b3a644dd4511d603ae2e6e064d51d6354..be91061ffa6e6b36418c81df3781989b3514736d 100644 (file)
$initialValue = $this->prefix.$this->property->getValue().$this->suffix;
$targetValue = $this->prefix.$this->property->getValue(TRUE).$this->suffix;
+ $prefix = $this->config->get_cfg_value('faiManagement','faiBaseRDN');
+
$dnMatch = "";
- if(!empty($initialValue)){
- foreach(preg_split("/,/", $initialValue) as $rdnPart){
+ if(!empty($initialValue) || !empty($prefix)){
+ foreach(preg_split("/,/", $initialValue.$prefix) as $rdnPart){
if(empty($rdnPart)) continue;
list($namingAttrs, $container) = preg_split("/=/",$rdnPart,2);
$container = trim($container,', ');
}
}
+ // Collect all FAI releases - this is nescessary to detect the release part
+ // of the dn
+ $ldap->cd($this->config->current['BASE']);
+ $releases = array();
+ $ldap->search("(objectClass=FAIbranch)",array('dn'));
+ while($attrs = $ldap->fetch()){
+ $releases[$attrs['dn']] = $attrs['dn'];
+ }
+
// Search for users
$filter = sprintf($this->filter,$dnMatch);
$ldap->search($filter,array('dn'));
$dn = $attrs['dn'];
$dnTo = $dn;
- // If there intially was no userDN given then just add the new userRDN to the user dns
- // and create the new container objects.
- if(empty($initialValue)){
- list($namingAttrs, $container) = preg_split("/=/",$targetValue,2);
- list($name, $container) = preg_split("/,/",$dn,2);
-
- // Ensure that we handle a valid gosaDepartment container.
- while(!isset($this->config->idepartments[$container])){
- $container = preg_replace("/^[^,]*+,/","",$container);
- }
+ // Detect the releaes part of the dn.
+ $releasePart = $dn;
+ while(!isset($releases[$releasePart]) && preg_match("/,/", $releasePart)){
+ $releasePart = preg_replace("/^[^,]*+,/","",$releasePart);
+ }
+ if(!isset($releases[$releasePart])){
+ // Release not found;
+ continue;
+ }
- // Queue new containuer to be created.
- if(!preg_match("/^".preg_quote($targetValue,'/i')."/", $container)){
- $dnTo = $name.",".$targetValue.$container;
- if(!$ldap->dn_exists($targetValue.$container)){
- $this->found['add'][$targetValue.$container] = array();
- }
- if($dn != $dnTo){
- $this->found['move'][] = array('from' => $dn, 'to' => $dnTo);
- $found = TRUE;
- }
- }
+ // Detect the base part of the releasePart
+ $basePart = $releasePart;
+ while(!isset($this->config->idepartments[$basePart]) && preg_match("/,/", $basePart)){
+ $basePart = preg_replace("/^[^,]*+,/","",$basePart);
+ }
+ if(!isset($this->config->idepartments[$basePart])){
+ // Base not found;
+ continue;
}
- // If there intially was a userDN given then replace it with the new one.
- if(!empty($initialValue)){
+ $releaseRDN = substr($releasePart,0,strlen($releasePart) - strlen($basePart));
- list($name, $container) = preg_split("/,/",$dn,2);
- if(preg_match("/^".preg_quote($initialValue,'/i')."/", $container)){
- $container = preg_replace("/^".preg_quote($initialValue,'/')."/",$targetValue,$container);
+ // Now remove the faiBaseRDN from the release DN.
+ $releaseRDN = preg_replace("/".preg_quote($prefix,'/')."/","", $releaseRDN);
- // Ensure that we handle a valid gosaDepartment container.
- while(!isset($this->config->idepartments[$container])){
- $container = preg_replace("/^[^,]*+,/","",$container);
- }
+ // Remove all parts from the dn to geht the objects name.
+ $name = substr($dn,0, (strlen($dn) - strlen($initialValue.$releaseRDN.$prefix.$basePart)));
+ // Build new container name and check if it exists.
+ $newContainer = $targetValue.$releaseRDN.$prefix.$basePart;
+ if(!$ldap->dn_exists($newContainer)){
+ $this->found['add'][$newContainer] = array();
+ }
- $dnTo = $name.",".$targetValue.$container;
- if(!empty($targetValue) && !$ldap->dn_exists($targetValue.$container)){
- $this->found['add'][$targetValue.$container] = array();
- }
- if($dn != $dnTo){
- $this->found['move'][] = array('from' => $dn, 'to' => $dnTo);
- $found = TRUE;
- }
- }
- }
+ // Check if the target name has changed.
+ $dnTo = $name.$newContainer;
+ if($dn != $dnTo){
+ $this->found['move'][] = array('from' => $dn, 'to' => $dnTo);
+ $found = TRUE;
+ }
}
return($found);
}