".$ldap->get_error().""), ERROR_DIALOG);
}else{
@@ -2322,10 +2661,16 @@ class Step_Migrate extends setup_step
}
}
}
+ $this->check_usb_devices();
}
-
+ /*! \brief Check for old style (gosa-2.5) services that have to be migrated
+ to be useable in gosa-2.6.
+ All required changes are stored in $this->service, also some
+ readable informations describing the actions required
+ to migrate the service
+ */
function check_services()
{
/* Establish ldap connection */
@@ -2377,7 +2722,7 @@ class Step_Migrate extends setup_step
*/
if(count($this->service)){
$this->checks['old_style_services']['STATUS'] = FALSE;
- $this->checks['old_style_services']['STATUS_MSG']= _("Failed");
+ $this->checks['old_style_services']['STATUS_MSG']= ""._("Warning")."";
$this->checks['old_style_services']['ERROR_MSG'] =
sprintf(_("There are %s services that need to be migrated."),
count($this->service)).
@@ -2390,7 +2735,12 @@ class Step_Migrate extends setup_step
}
- function migrate_usb_services()
+
+ /*! \brief Migrate selected services.
+ This function executes the commands collected by the
+ service_check() function.
+ */
+ function migrate_services()
{
/* Establish ldap connection
*/
@@ -2418,7 +2768,7 @@ class Step_Migrate extends setup_step
*/
if(!$ldap->success()){
msg_dialog::display(_("LDAP error"),
- sprintf(_("Ldap update failed for %s with error %s"),
+ sprintf(_("Updating '%s' failed: %s"),
"".LDAP::fix($service['DN'])."",
"
".$ldap->get_error().""), ERROR_DIALOG);
}else{
@@ -2430,9 +2780,16 @@ class Step_Migrate extends setup_step
}
}
}
+
+ /* Update the service migration status
+ */
+ $this->check_services();
}
+ /*! \brief Ensure that posts made on the service migration dialog
+ are processed.
+ */
function check_service_posts()
{
foreach($this->service as $key => $service){
@@ -2445,11 +2802,14 @@ class Step_Migrate extends setup_step
}
+ /*! \brief This function checks the given ldap for old style (gosa-2.5)
+ menu entries and will prepare a list of actions that are required
+ to migrate them to gosa-2.6.
+ All required actions and some readable informations are stored in
+ $this->menu.
+ */
function check_menus()
{
-
- $start = microtime(1);
-
/* Establish ldap connection
*/
$cv = $this->parent->captured_values;
@@ -2475,18 +2835,11 @@ class Step_Migrate extends setup_step
return;
}
-
- $releases = array();
- while($attrs = $ldap->fetch()){
- if(preg_match("/,ou=fai,/",$attrs['dn']) && in_array("organizationalUnit",$attrs['objectClass'])){
- $tmp = split("\,",$attrs['dn']);
- $fai_base = preg_replace("/,ou=fai,.*$/","",$attrs['dn']);
- $releases[convert_department_dn($fai_base,$cv['base'])] = $attrs['dn'];
- }
- }
-
-
+ /* Create application -> parameter mapping, used later to detect
+ which configured parameter belongs to which application entry.
+ */
$amap= array();
+ $todo = array();
$ldap->cd($cv['base']);
$ldap->search("(objectClass=gosaApplication)", array("cn", "gosaApplicationParameter"));
while($info = $ldap->fetch()){
@@ -2503,16 +2856,17 @@ class Step_Migrate extends setup_step
}
}
- /* Search for all groups */
+ /* Search for all groups that have an old style application menu configured.
+ */
+ $appgroups = array();
$ldap->cd($cv['base']);
$ldap->search("(&(objectClass=gosaApplicationGroup)(objectClass=posixGroup)(FAIrelease=*))",
- array("gosaMemberApplication","gosaApplicationParameter","FAIrelease","objectClass"));
- $appgroups = array();
+ array("gosaMemberApplication","gosaApplicationParameter","FAIrelease","objectClass","gosaUnitTag"));
/* Create readable prefix for "What will be done" infos
*/
- $s_add = ""._("add")."\t";
- $s_del = ""._("remove")."\t";
+ $s_add = ""._("Add")."\t";
+ $s_del = ""._("Remove")."\t";
/* Walk through all found old-style menu configurations.
-Prepare ldap update list $data
@@ -2524,6 +2878,13 @@ class Step_Migrate extends setup_step
$current = "";
$after ="";
+ /* Get unit tag
+ */
+ $tag ="";
+ if(isset($info['gosaUnitTag'])){
+ $tag = $info['gosaUnitTag'][0];
+ }
+
/* Collect application parameter for this group
*/
$params= array();
@@ -2534,17 +2895,17 @@ class Step_Migrate extends setup_step
}
}
- /* Create release dn part.
- eg. "sisa/1.0.0" => "ou=1.0.0,ou=siga,"
+ /* Create release container for each release/subrelease.
+ eg. "sisa/1.0.0":
+ . "ou=siga, ..."
+ . "ou=1.0.0,ou=siga, .."
*/
$release = "";
$r = $info['FAIrelease'][0];
- $z = split("/",$r);
+ $z = explode("/",$r);
foreach($z as $part){
- if(empty($part)){
- echo __LINE__; exit();
- }else{
+ if(!empty($part)){
$release = "ou=".$part.",".$release;
/* Append release department information to "What will be done" info
@@ -2554,12 +2915,23 @@ class Step_Migrate extends setup_step
$after .= $s_add."objectClass: top\n";
$after .= $s_add."objectClass: FAIbranch\n";
$after .= $s_add."objectClass: organizationalUnit\n";
+
+ /* Append UnitTag
+ */
+ if($tag != ""){
+ $after .= $s_add."objectClass: gosaAdministrativeUnitTag\n";
+ $after .= $s_add."gosaUnitTag: $tag\n";
+ }
$after .= $s_add."ou: $part\n";
- /* Appen release data to ldap actions
+ /* Append release data to ldap actions
*/
$d = array();
$d['objectClass'] = array("top","FAIbranch","organizationalUnit");
+ if(!empty($tag)){
+ $d['objectClass'][] = "gosaAdministrativeUnitTag";
+ $d['gosaUnitTag'] = $tag;
+ }
$d['ou'] = $part;
$data['ADD'][$release_dn]= $d;
}
@@ -2583,7 +2955,7 @@ class Step_Migrate extends setup_step
*/
$current .= $s_del."gosaMemberApplication: ".$info['gosaMemberApplication'][$i]."\n";
- /* Append ldap update action to remove the old menu entry
+ /* Append ldap update action to remove the old menu entry attributes
*/
unset($info['objectClass']['count']);
$d = array();
@@ -2606,29 +2978,49 @@ class Step_Migrate extends setup_step
$after .= "\n";
$after .= $s_add."dn: $location_dn$release_dn\n";
$after .= $s_add."objectClass: gotoSubmenuEntry\n";
- $after .= $s_add."cn: $location\n";
+ /* Append UnitTag
+ */
+ if($tag != ""){
+ $after .= $s_add."objectClass: gosaAdministrativeUnitTag\n";
+ $after .= $s_add."gosaUnitTag: $tag\n";
+ }
+ $after .= $s_add."cn: $location\n";
+
+ /* Create ldap entry to append
+ */
$d = array();
$d['cn'] = $location;
$d['objectClass'] = array("gotoSubmenuEntry");
+ if(!empty($tag)){
+ $d['objectClass'][] = "gosaAdministrativeUnitTag";
+ $d['gosaUnitTag'] = $tag;
+ }
$data['ADD'][$location_dn.$release_dn] = $d;
}
-
- /* Append missing menu entry to "What is done info"
+ /* Append missing menu entry for "What is done info".
*/
- if(empty($name)){
- echo __LINE__; exit();
- }else{
+ if(!empty($name)){
$after .= "\n";
$after .= $s_add."dn: cn=$name,$location_dn$release_dn\n";
$after .= $s_add."objectClass: gotoMenuEntry\n";
+ if($tag != ""){
+ $after .= $s_add."objectClass: gosaAdministrativeUnitTag\n";
+ $after .= $s_add."gosaUnitTag: $tag\n";
+ }
$after .= $s_add."cn: $name\n";
$after .= $s_add."gosaApplicationPriority: $priority\n";
+ /* Create ldap entry
+ */
$d= array();
$d['objectClass'] = array("gotoMenuEntry");
+ if(!empty($tag)){
+ $d['objectClass'][] = "gosaAdministrativeUnitTag";
+ $d['gosaUnitTag'] = $tag;
+ }
$d['cn'] = $name;
$d['gosaApplicationPriority'] = $priority;
@@ -2642,7 +3034,9 @@ class Step_Migrate extends setup_step
}
}
}
-
+
+ /* Updated todo list
+ */
$todo[] = array(
"DETAILS" => FALSE,
"DN" => $info['dn'],
@@ -2651,6 +3045,9 @@ class Step_Migrate extends setup_step
"TODO" => $data
);
}
+
+ /* Remember checks.
+ */
$this->menu = $todo;
/* Check if we were able to query the ldap server
@@ -2658,16 +3055,19 @@ class Step_Migrate extends setup_step
if(count($this->menu)){
$this->checks['old_style_menus']['STATUS'] = FALSE;
$this->checks['old_style_menus']['STATUS_MSG']= ""._("Warning")."";
- $this->checks['old_style_menus']['ERROR_MSG'] = sprintf(_("There are %s application menus which have to be converted."),
+ $this->checks['old_style_menus']['ERROR_MSG'] = sprintf(_("There are %s application menus which have to be migrated."),
count($this->menu))."";
}else{
$this->checks['old_style_menus']['STATUS'] = TRUE;
$this->checks['old_style_menus']['STATUS_MSG']= _("Ok");
$this->checks['old_style_menus']['ERROR_MSG'] = "";
-
}
}
+
+ /*! \brief Handle posts for the menu_dialog
+ Ensure that checked checkboxes stay checked.
+ */
function check_menu_posts()
{
foreach($this->menu as $key => $menu){
@@ -2679,7 +3079,13 @@ class Step_Migrate extends setup_step
}
}
- function migrate_usb_menus()
+
+ /*! \brief This function updates old-style application menus to
+ valid 2.6 application menus.
+ All selected menus will be converted (DETAILS = TRUE).
+ The ldap actions collected by check_menus() will be executed.
+ */
+ function migrate_menus()
{
/* Establish ldap connection
@@ -2692,21 +3098,19 @@ class Step_Migrate extends setup_step
$cv['tls']);
$ldap = new ldapMultiplexer($ldap_l);
-
- /* First detect all release names
- */
$ldap->cd($cv['base']);
+ /* Walk through menus and detect selected menu
+ */
foreach($this->menu as $key => $menu){
if($menu['DETAILS']) {
+ /* Excute all LDAP-ADD actions
+ */
$success = TRUE;
foreach($menu['TODO']['ADD'] as $dn => $data){
$ldap->cd($cv['base']);
- $base = preg_replace("/^[^,]+,/","",$dn);
- if(!$ldap->dn_exists($base)){
- echo "FEHLER !!! ES FEHLT : ".$base." ";
- }elseif(!$ldap->dn_exists($dn)){
+ if(!$ldap->dn_exists($dn)){
$ldap->cd($dn);
$ldap->add($data);
if (!$ldap->success()){
@@ -2716,10 +3120,11 @@ class Step_Migrate extends setup_step
}
}
+ /* Execute all LDAP-MODIFY actions
+ */
foreach($menu['TODO']['MODIFY'] as $dn => $data){
- if(!$ldap->dn_exists($dn)){
- echo "FEHLER !!! ES FEHLT : ".$dn." ";
- }else{
+ $ldap->cd($cv['base']);
+ if($ldap->dn_exists($dn)){
$ldap->cd($dn);
$ldap->modify($data);
if (!$ldap->success()){
@@ -2728,13 +3133,161 @@ class Step_Migrate extends setup_step
}
}
}
+
+ /* If every action was successful, remove this entry from the list
+ */
if($success){
unset($this->menu[$key]);
}
}
}
+
+ /* Udpate migration status for application menus
+ */
+ $this->check_menus();
}
-}
+
+ function migrate_selected_admin_users()
+ {
+ /* Updated ui selection */
+ $this->migrate_users();
+
+ /* Establish ldap connection */
+ $cv = $this->parent->captured_values;
+ $ldap_l = new LDAP($cv['admin'],
+ $cv['password'],
+ $cv['connection'],
+ FALSE,
+ $cv['tls']);
+
+ $ldap = new ldapMultiplexer($ldap_l);
+ $ldap->cd($cv['base']);
+
+ /* Get current ACL configuration for the ldap base
+ */
+ $ldap->cat($cv['base']);
+ $base_attrs = $ldap->fetch();
+ $acl_entries= array();
+ $acl_id = -1;
+ if(isset($base_attrs['gosaAclEntry'])){
+ for($i=0; $i < $base_attrs['gosaAclEntry']['count']; $i ++){
+ $acl_entries[] = $base_attrs['gosaAclEntry'][$i];
+ $cur_id = preg_replace("/^([0-9]*):.*$/","\\1",$base_attrs['gosaAclEntry'][$i]);
+ if($cur_id > $acl_id){
+ $acl_id = $cur_id;
+ }
+ }
+ }
+
+ /* Append ACLs selected in the migrate admin account dialog
+ */
+ foreach($this->migrate_users as $entry){
+ if($entry['checked']){
+ $acl_id ++;
+ $acl_entries[] = $acl_id.$entry['change'];
+ }
+ }
+
+ /* Check if the required objectClasses are available
+ */
+ $ocs = array();
+ for($i=0;$i< $base_attrs['objectClass']['count']; $i++){
+ $ocs[] = $base_attrs['objectClass'][$i];
+ }
+ if(!in_array("gosaACL",$ocs)){
+ $ocs[] = "gosaACL";
+ }
+
+ /* Try to write changes
+ */
+ if(count($acl_entries)){
+ $new_entry['gosaAclEntry'] = $acl_entries;
+ $new_entry['objectClass'] = $ocs;
+ $ldap->cd($cv['base']);
+ $ldap->modify($new_entry);
+ if(!$ldap->success()){
+ $this->checks['acls']['TITLE'] = _("Checking for super administrator");
+ $this->checks['acls']['STATUS'] = FALSE;
+ $this->checks['acls']['STATUS_MSG']= _("Failed");
+ $this->checks['acls']['ERROR_MSG'] = " ".msgPool::ldaperror($cv['base'],$ldap->get_error(),LDAP_MOD);
+ }else{
+ $this->check_administrativeAccount();
+ }
+ }
+ }
+
+
+ function migrate_users()
+ {
+ /* Collect a list of available GOsa users and groups
+ */
+
+ /* Establish ldap connection */
+ $cv = $this->parent->captured_values;
+ $ldap_l = new LDAP($cv['admin'],
+ $cv['password'],
+ $cv['connection'],
+ FALSE,
+ $cv['tls']);
+
+ $ldap = new ldapMultiplexer($ldap_l);
+ $ldap->cd($cv['base']);
+
+ $users = array();
+ $ldap->search("(&(objectClass=gosaAccount)(objectClass=person)".
+ "(objectClass=inetOrgPerson)(objectClass=organizationalPerson))",array("uid","dn"));
+ while($user_attrs = $ldap->fetch()){
+ $users[$user_attrs['dn']] = $user_attrs['uid'][0];
+ $rusers[$user_attrs['uid'][0]] = $user_attrs['dn'];
+ }
+ $groups = array();
+ $ldap->search("objectClass=posixGroup",array("cn","dn"));
+ while($group_attrs = $ldap->fetch()){
+ $groups[$group_attrs['dn']] = $group_attrs['cn'][0];
+ }
+
+ foreach($this->migrate_users as $id => $data){
+ $this->migrate_users[$id]['checked'] = isset($_POST['migrate_admin_'.$id]);
+ }
+
+ /* Try to find an old GOsa 2.5 administrative account that may be migrated
+ */
+ if(!count($this->migrate_users)){
+ $ldap->cat($cv['base']);
+ $base_data = $ldap->fetch();
+ $base_entry = "dn: ".$base_data['dn']."\n";
+ for($i=0;$i<$base_data['objectClass']['count'];$i++){
+ $base_entry .= "objectClass: ".$base_data['objectClass'][$i]."\n";
+ }
+ if(!in_array("gosaACL",$base_data['objectClass'])){
+ $base_entry .= "objectClass: gosaACL\n";
+ }
+ if(isset($base_data['gosaAclEntry'])){
+ for($i=0;$i<$base_data['gosaAclEntry']['count'];$i++){
+ $base_entry .= "gosaAclEntry: ".$base_data['gosaAclEntry'][$i]."\n";
+ }
+ }
+ $this->migrate_acl_base_entry = $base_entry;
+ $ldap->cd($cv['base']);
+ $ldap->search("(&(objectClass=posixGroup)(gosaSubtreeACL=:all)(memberUid=*))",array("memberUid","cn"));
+ while($p_group = $ldap->fetch()){
+ for($e = 0 ; $e < $p_group['memberUid']['count'] ; $e ++ ){
+ $user = $p_group['memberUid'][$e];
+ if(isset($rusers[$user])){
+ $bsp_acl_entry = "gosaAclEntry: #:psub:".base64_encode($rusers[$user]).":all;cmdrw\n";
+ $entry = array();
+ $entry['uid'] = $user;
+ $entry['dn'] = $rusers[$user];
+ $entry['details'] = $bsp_acl_entry;
+ $entry['checked'] = FALSE;
+ $entry['change'] = ":psub:".base64_encode($rusers[$user]).":all;cmdrw";
+ $this->migrate_users[] = $entry;
+ }
+ }
+ }
+ }
+ }
+}
// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
?>