Code

Added scalix and nagios accounts.
[gosa.git] / gosa-core / setup / class_setupStep_Migrate.inc
index cef6eefed2d100a5b2300f8f08400545443c2d79..9f20ab6a24425da072d9f29020a91d6ded8081e6 100644 (file)
@@ -82,6 +82,18 @@ class Step_Migrate extends setup_step
   var $outside_groups        = array();
   var $outside_groups_dialog = FALSE;
 
+  /* Device migration */
+  var $device_dialog         = FALSE;
+  var $device                = array();
+
+  /* Service migration */
+  var $service_dialog         = FALSE;
+  var $service                = array();
+
+  /* Group menus */
+  var $menu_dialog           = FALSE;
+  var $menu                  = array();
+
   /* Win-Workstations outside to reserved ou */
   var $outside_winstations        = array();
   var $outside_winstations_dialog = FALSE;
@@ -94,6 +106,7 @@ class Step_Migrate extends setup_step
   var $check_gidNumbers        = array();
   var $check_gidNumbers_dialog = FALSE;
 
+  var $group_list              = array();
 
   function Step_Migrate()
   {
@@ -126,7 +139,6 @@ class Step_Migrate extends setup_step
     $this->checks['deps_visible']['STATUS']    = FALSE;
     $this->checks['deps_visible']['STATUS_MSG']= "";
     $this->checks['deps_visible']['ERROR_MSG'] = "";
-    $this->check_organizationalUnits();
 
     $this->checks['users_visible']['TITLE']     = _("Checking for invisible users");
     $this->checks['users_visible']['STATUS']    = FALSE;
@@ -145,12 +157,13 @@ class Step_Migrate extends setup_step
     $this->checks['outside_users']['STATUS_MSG']= "";
     $this->checks['outside_users']['ERROR_MSG'] = "";
     $this->search_outside_users();
-    
+
     $this->checks['outside_groups']['TITLE']     = _("Checking for groups outside the groups tree");
     $this->checks['outside_groups']['STATUS']    = FALSE;
     $this->checks['outside_groups']['STATUS_MSG']= "";
     $this->checks['outside_groups']['ERROR_MSG'] = "";
     $this->search_outside_groups();
+    $this->check_organizationalUnits();
 
     $this->checks['outside_winstations']['TITLE']     = _("Checking for windows workstations outside the winstation tree");
     $this->checks['outside_winstations']['STATUS']    = FALSE;
@@ -158,17 +171,35 @@ class Step_Migrate extends setup_step
     $this->checks['outside_winstations']['ERROR_MSG'] = "";
     $this->search_outside_winstations();
 
-    $this->checks['uidNumber_usage']['TITLE']     = _("Checking for duplicate uid numbers");
+    $this->checks['uidNumber_usage']['TITLE']     = _("Checking for duplicated UID numbers");
     $this->checks['uidNumber_usage']['STATUS']    = FALSE;
     $this->checks['uidNumber_usage']['STATUS_MSG']= "";
     $this->checks['uidNumber_usage']['ERROR_MSG'] = "";
     $this->check_uidNumber();
-    
-    $this->checks['gidNumber_usage']['TITLE']     = _("Checking for duplicate gid numbers");
+
+    $this->checks['gidNumber_usage']['TITLE']     = _("Checking for duplicate GID numbers");
     $this->checks['gidNumber_usage']['STATUS']    = FALSE;
     $this->checks['gidNumber_usage']['STATUS_MSG']= "";
     $this->checks['gidNumber_usage']['ERROR_MSG'] = "";
     $this->check_gidNumber();
+
+    $this->checks['old_style_devices']['TITLE']     = _("Checking for old style USB devices");
+    $this->checks['old_style_devices']['STATUS']    = FALSE;
+    $this->checks['old_style_devices']['STATUS_MSG']= "";
+    $this->checks['old_style_devices']['ERROR_MSG'] = "";
+    $this->check_usb_devices();
+
+    $this->checks['old_style_services']['TITLE']     = _("Checking for old services that have to be migrated");
+    $this->checks['old_style_services']['STATUS']    = FALSE;
+    $this->checks['old_style_services']['STATUS_MSG']= "";
+    $this->checks['old_style_services']['ERROR_MSG'] = "";
+    $this->check_services();
+
+    $this->checks['old_style_menus']['TITLE']     = _("Checking for old style application menus");
+    $this->checks['old_style_menus']['STATUS']    = FALSE;
+    $this->checks['old_style_menus']['STATUS_MSG']= "";
+    $this->checks['old_style_menus']['ERROR_MSG'] = "";
+    $this->check_menus();
   }
 
 
@@ -176,15 +207,18 @@ class Step_Migrate extends setup_step
    */
   function check_uidNumber()
   {
+    /* Establish ldap connection */
     $cv = $this->parent->captured_values;
-    $ldap = new LDAP($cv['admin'],
+    $ldap_l = new LDAP($cv['admin'],
         $cv['password'],
         $cv['connection'],
         FALSE,
         $cv['tls']);
 
+    $ldap = new ldapMultiplexer($ldap_l);
+
     $ldap->cd($cv['base']);
-    $res = $ldap->search("uidNumber=*",array("dn","uidNumber"));
+    $res = $ldap->search("(&(objectClass=posixAccount)(uidNumber=*))",array("dn","uidNumber"));
     if(!$res){
       $this->checks['uidNumber_usage']['STATUS']    = FALSE;
       $this->checks['uidNumber_usage']['STATUS_MSG']= _("LDAP query failed");
@@ -225,13 +259,16 @@ class Step_Migrate extends setup_step
    */
   function check_gidNumber()
   {
+    /* Establish ldap connection */
     $cv = $this->parent->captured_values;
-    $ldap = new LDAP($cv['admin'],
+    $ldap_l = new LDAP($cv['admin'],
         $cv['password'],
         $cv['connection'],
         FALSE,
         $cv['tls']);
 
+    $ldap = new ldapMultiplexer($ldap_l);
+
     $ldap->cd($cv['base']);
     $res = $ldap->search("(&(objectClass=posixGroup)(gidNumber=*))",array("dn","gidNumber"));
     if(!$res){
@@ -274,16 +311,19 @@ class Step_Migrate extends setup_step
    */
   function search_outside_winstations()
   {
+    /* Establish ldap connection */
     $cv = $this->parent->captured_values;
-    $ldap = new LDAP($cv['admin'],
+    $ldap_l = new LDAP($cv['admin'],
         $cv['password'],
         $cv['connection'],
         FALSE,
         $cv['tls']);
 
+    $ldap = new ldapMultiplexer($ldap_l);
+
     /* Get winstation ou */
     if($cv['generic_settings']['wws_ou_active']) {
-      $winstation_ou = $cv['generic_settings']['ws_ou'];
+      $winstation_ou = $cv['generic_settings']['wws_ou'];
     }else{
       $winstation_ou = "ou=winstations";
     }
@@ -332,13 +372,16 @@ class Step_Migrate extends setup_step
    */
   function search_outside_groups()
   {
+    /* Establish ldap connection */
     $cv = $this->parent->captured_values;
-    $ldap = new LDAP($cv['admin'],
+    $ldap_l = new LDAP($cv['admin'],
         $cv['password'],
         $cv['connection'],
         FALSE,
         $cv['tls']);
 
+    $ldap = new ldapMultiplexer($ldap_l);
+
     $group_ou = $cv['groupou'];
     $ldap->cd($cv['base']);
 
@@ -365,6 +408,7 @@ class Step_Migrate extends setup_step
     }
 
     $this->outside_groups = array();
+    $this->groups_list = array();;
     while($attrs = $ldap->fetch()){
       $group_db_base = preg_replace("/^[^,]+,".normalizePreg($group_ou)."+,/i","",$attrs['dn']);
 
@@ -378,6 +422,7 @@ class Step_Migrate extends setup_step
         $attrs['ldif']     = "";
         $this->outside_groups[base64_encode($attrs['dn'])] = $attrs;
       }
+      $this->group_list[] = $attrs['dn'];
     }
 
     if(count($this->outside_groups)){
@@ -399,13 +444,15 @@ class Step_Migrate extends setup_step
    */
   function search_outside_users()
   {
+    /* Establish ldap connection */
     $cv = $this->parent->captured_values;
-    $ldap = new LDAP($cv['admin'],
+    $ldap_l = new LDAP($cv['admin'],
         $cv['password'],
         $cv['connection'],
         FALSE,
         $cv['tls']);
 
+    $ldap = new ldapMultiplexer($ldap_l);
     $ldap->cd($cv['base']);
 
 
@@ -477,13 +524,16 @@ class Step_Migrate extends setup_step
    */
   function check_ldap_permissions()
   {
+    /* Establish ldap connection */
     $cv = $this->parent->captured_values;
-    $ldap = new LDAP($cv['admin'],
+    $ldap_l = new LDAP($cv['admin'],
         $cv['password'],
         $cv['connection'],
         FALSE,
         $cv['tls']);
 
+    $ldap = new ldapMultiplexer($ldap_l);
+
     /* Create dummy entry 
      */
     $name     = "GOsa_setup_text_entry_".session_id().rand(0,999999);
@@ -554,16 +604,16 @@ class Step_Migrate extends setup_step
     $old    = $this->users_to_migrate;
     $this->users_to_migrate = array();
 
-    /* Get collected configuration settings */
-    $cv = $this->parent->captured_values;
-
     /* Establish ldap connection */
-    $ldap = new LDAP($cv['admin'],
+    $cv = $this->parent->captured_values;
+    $ldap_l = new LDAP($cv['admin'],
         $cv['password'],
         $cv['connection'],
         FALSE,
         $cv['tls']);
 
+    $ldap = new ldapMultiplexer($ldap_l);
+
     /* Get all invisible users 
      */
     $ldap->cd($cv['base']); 
@@ -607,16 +657,16 @@ class Step_Migrate extends setup_step
   {
     $this->show_details= $only_ldif;
 
-    /* Get collected configuration settings */
-    $cv = $this->parent->captured_values;
-
     /* Establish ldap connection */
-    $ldap = new LDAP($cv['admin'],
+    $cv = $this->parent->captured_values;
+    $ldap_l = new LDAP($cv['admin'],
         $cv['password'],
         $cv['connection'],
         FALSE,
         $cv['tls']);
 
+    $ldap = new ldapMultiplexer($ldap_l);
+
     /* Add gosaAccount objectClass to the selected users  
      */
     foreach($this->users_to_migrate as $key => $dep){
@@ -662,18 +712,18 @@ class Step_Migrate extends setup_step
     $old = $this->deps_to_migrate;
     $this->deps_to_migrate = array();
 
-    /* Get collected configuration settings */
-    $cv = $this->parent->captured_values;
-
     /* Establish ldap connection */
-    $ldap = new LDAP($cv['admin'],
+    $cv = $this->parent->captured_values;
+    $ldap_l = new LDAP($cv['admin'],
         $cv['password'],
         $cv['connection'],
         FALSE,
         $cv['tls']);
 
+    $ldap = new ldapMultiplexer($ldap_l);
+
     /* Skip GOsa internal departments */
-    $skip_dns = array("/".$cv['peopleou']."/","/".$cv['groupou']."/","/^ou=people,/","/^ou=groups,/",
+    $skip_dns = array("/".$cv['peopleou']."/","/".$cv['groupou']."/","/^ou=people,/","/^ou=groups,/","/^ou=sudoers,/",
         "/(,|)ou=configs,/","/(,|)ou=systems,/",
         "/(,|)ou=apps,/","/(,|)ou=mime,/","/(,|)ou=devices/","/^ou=aclroles,/","/^ou=incoming,/",
         "/ou=snapshots,/","/(,|)dc=addressbook,/","/^(,|)ou=machineaccounts,/",
@@ -700,6 +750,17 @@ class Step_Migrate extends setup_step
     foreach($this->deps_to_migrate as $key => $attrs){
       $dn = $attrs['dn'];
       $skip = false;;
+
+      /* Check if this object is an application release object
+          e.g. groups-> application menus.
+       */
+      if(preg_match("/^.*,[ ]*cn=/",$dn)){
+        $cn_dn = preg_replace("/^.*,[ ]*cn=/","cn=",$dn);
+        if(in_array($cn_dn,$this->group_list)){
+          $skip = true;
+        }
+      }
+    
       foreach($skip_dns as $skip_dn){
         if(preg_match($skip_dn,$dn)){
           $skip = true;
@@ -736,16 +797,16 @@ class Step_Migrate extends setup_step
   {
     $this->show_details= $only_ldif;
 
-    /* Get collected configuration settings */
-    $cv = $this->parent->captured_values;
-
     /* Establish ldap connection */
-    $ldap = new LDAP($cv['admin'],
+    $cv = $this->parent->captured_values;
+    $ldap_l = new LDAP($cv['admin'],
         $cv['password'],
         $cv['connection'],
         FALSE,
         $cv['tls']);
 
+    $ldap = new ldapMultiplexer($ldap_l);
+
     /* Add gosaDepartment objectClass to each selected entry 
      */
     foreach($this->deps_to_migrate as $key => $dep){
@@ -792,13 +853,13 @@ class Step_Migrate extends setup_step
   {
     /* Establish ldap connection */
     $cv = $this->parent->captured_values;
-    $ldap = new LDAP($cv['admin'],
+    $ldap_l = new LDAP($cv['admin'],
         $cv['password'],
         $cv['connection'],
         FALSE,
         $cv['tls']);
 
-    /* Search for gosaAcls */ 
+    $ldap = new ldapMultiplexer($ldap_l);
     $ldap->cd($cv['base']);
     $res = $ldap->cat($cv['base']);
     
@@ -899,19 +960,22 @@ class Step_Migrate extends setup_step
     /* Get collected configuration settings */
     $cv = $this->parent->captured_values;
 
-    /* Establish ldap connection */
-    $ldap = new LDAP($cv['admin'],
+    /* On first call check for rid/sid base */
+    $ldap_l = new LDAP($cv['admin'],
         $cv['password'],
         $cv['connection'],
         FALSE,
         $cv['tls']);
 
+    $ldap = new ldapMultiplexer($ldap_l);
+
     /* Get current base attributes */
     $ldap->cd($cv['base']);
     $ldap->cat($cv['base'],array("dn","objectClass","gosaAclEntry"));
     $attrs = $ldap->fetch();
 
     /* Add acls for the selcted user to the base */
+    $attrs_new = array();
     $attrs_new['objectClass'] = array("gosaACL");
 
     for($i = 0; $i < $attrs['objectClass']['count']; $i ++){
@@ -955,6 +1019,16 @@ class Step_Migrate extends setup_step
   {
     $pw1 = $pw2 = "";
     $uid = "";
+
+    /* On first call check for rid/sid base */
+    $cv = $this->parent->captured_values;
+    $ldap_l = new LDAP($cv['admin'],
+        $cv['password'],
+        $cv['connection'],
+        FALSE,
+        $cv['tls']);
+
+    $ldap = new ldapMultiplexer($ldap_l);
   
     if(isset($_POST['new_user_uid'])){
       $uid = $_POST['new_user_uid'];
@@ -966,6 +1040,14 @@ class Step_Migrate extends setup_step
       $pw2 = $_POST['new_user_password2'];
     }
   
+    
+    $ldap->cd($cv['base']);
+    $ldap->search("(uid=".$uid.")");
+    if($ldap->count()){
+      msg_dialog::display(_("Input error"),msgPool::duplicated(_("Uid")), ERROR_DIALOG);
+      return false;
+    }
+    
     if(empty($pw1) || empty($pw2) | ($pw1 != $pw2)){
       msg_dialog::display(_("Password error"), _("Provided passwords do not match!"), ERROR_DIALOG);
       return false;
@@ -975,16 +1057,8 @@ class Step_Migrate extends setup_step
       msg_dialog::display(_("Input error"), _("Specify a valid user ID!"), ERROR_DIALOG);
       return false;
     }
-    
-
-    /* Establish ldap connection */
-    $cv = $this->parent->captured_values;
-    $ldap = new LDAP($cv['admin'],
-        $cv['password'],
-        $cv['connection'],
-        FALSE,
-        $cv['tls']);
-
     /* Get current base attributes */
     $ldap->cd($cv['base']);
   
@@ -994,21 +1068,18 @@ class Step_Migrate extends setup_step
     }
 
     if($cv['peopledn'] == "cn"){
-      $dn = "cn=System Administrator,".$people_ou.$cv['base'];
+      $dn = "cn=System Administrator-".$uid.",".$people_ou.$cv['base'];
     }else{
       $dn = "uid=".$uid.",".$people_ou.$cv['base'];
     }
 
-    $methods = @passwordMethod::get_available_methods();
-    $p_m = $methods[$cv['encryption']];
-    $p_c = new $p_m(array());
-    $hash = $p_c->generate_hash($pw2);
+    $hash = passwordMethod::make_hash($pw2, $cv['encryption']);
 
     $new_user=array();
     $new_user['objectClass']= array("top","person","gosaAccount","organizationalPerson","inetOrgPerson");
     $new_user['givenName']  = "System";
     $new_user['sn']  = "Administrator";
-    $new_user['cn']  = "System Administrator";
+    $new_user['cn']  = "System Administrator-".$uid;
     $new_user['uid'] = $uid;
     $new_user['userPassword'] = $hash;
    
@@ -1041,12 +1112,14 @@ class Step_Migrate extends setup_step
   {
     /* Establish ldap connection */
     $cv = $this->parent->captured_values;
-    $ldap = new LDAP($cv['admin'],
+    $ldap_l = new LDAP($cv['admin'],
         $cv['password'],
         $cv['connection'],
         FALSE,
         $cv['tls']);
 
+    $ldap = new ldapMultiplexer($ldap_l);
+
     $ldap->cd($cv['base']);
 
     /* Check if there was a destination department posted */
@@ -1089,12 +1162,13 @@ class Step_Migrate extends setup_step
   {
     /* Establish ldap connection */
     $cv = $this->parent->captured_values;
-    $ldap = new LDAP($cv['admin'],
+    $ldap_l = new LDAP($cv['admin'],
         $cv['password'],
         $cv['connection'],
         FALSE,
         $cv['tls']);
 
+    $ldap = new ldapMultiplexer($ldap_l);
     $ldap->cd($cv['base']);
 
     /* Check if there was a destination department posted */
@@ -1137,12 +1211,13 @@ class Step_Migrate extends setup_step
   {
     /* Establish ldap connection */
     $cv = $this->parent->captured_values;
-    $ldap = new LDAP($cv['admin'],
+    $ldap_l = new LDAP($cv['admin'],
         $cv['password'],
         $cv['connection'],
         FALSE,
         $cv['tls']);
 
+    $ldap = new ldapMultiplexer($ldap_l);
     $ldap->cd($cv['base']);
 
     /* Check if there was a destination department posted */
@@ -1503,6 +1578,138 @@ class Step_Migrate extends setup_step
       return($smarty->fetch(get_template_path("setup_migrate.tpl",TRUE,dirname(__FILE__))));
     }
 
+
+    /*************
+     * Device migration 
+     *************/
+   
+    if($this->device_dialog) {
+      $this->check_device_posts();
+    }
+    if(isset($_POST['device_dialog_cancel'])){
+      $this->device_dialog = FALSE;
+      $this->show_details = FALSE;
+      $this->dialog = FALSE;
+    }
+   
+    if(isset($_POST['device_dialog_whats_done'])){
+      $this->show_details= TRUE;
+    }
+    if(isset($_POST['device_dialog_refresh'])){
+      $this->show_details= FALSE;
+    }
+
+    if(isset($_POST['migrate_devices'])){
+      $this->migrate_usb_devices();
+#      $this->dialog = FALSE;
+ #     $this->show_details = FALSE;
+  #    $this->device_dialog = FALSE;
+   #   $this->initialize_checks();
+    }
+
+    if(isset($_POST['device_dialog'])){
+      $this->device_dialog = TRUE;
+      $this->dialog = TRUE;
+    }
+    
+    if($this->device_dialog){
+      $smarty = get_smarty();
+      $smarty->assign("method","devices");
+      $smarty->assign("devices",$this->device);
+      $smarty->assign("device_details", $this->show_details);
+      return($smarty->fetch(get_template_path("setup_migrate.tpl",TRUE,dirname(__FILE__))));
+    }
+
+
+    /*************
+     * Service migration 
+     *************/
+   
+    if($this->service_dialog) {
+      $this->check_service_posts();
+    }
+    if(isset($_POST['service_dialog_cancel'])){
+      $this->service_dialog = FALSE;
+      $this->show_details = FALSE;
+      $this->dialog = FALSE;
+    }
+   
+    if(isset($_POST['service_dialog_whats_done'])){
+      $this->show_details= TRUE;
+    }
+    if(isset($_POST['service_dialog_refresh'])){
+      $this->show_details= FALSE;
+    }
+
+    if(isset($_POST['migrate_services'])){
+      $this->migrate_services();
+#      $this->dialog = FALSE;
+ #     $this->show_details = FALSE;
+  #    $this->service_dialog = FALSE;
+   #   $this->initialize_checks();
+    }
+
+    if(isset($_POST['service_dialog'])){
+      $this->service_dialog = TRUE;
+      $this->dialog = TRUE;
+    }
+    
+    if($this->service_dialog){
+      $smarty = get_smarty();
+      $smarty->assign("method","services");
+      $smarty->assign("services",$this->service);
+      $smarty->assign("service_details", $this->show_details);
+      return($smarty->fetch(get_template_path("setup_migrate.tpl",TRUE,dirname(__FILE__))));
+    }
+
+
+    /*************
+     * Menu migration 
+     *************/
+   
+    if($this->menu_dialog) {
+      $this->check_menu_posts();
+    }
+    if(isset($_POST['menu_dialog_cancel'])){
+      $this->menu_dialog = FALSE;
+      $this->show_details = FALSE;
+      $this->dialog = FALSE;
+    }
+   
+    if(isset($_POST['menu_dialog_whats_done'])){
+      $this->show_details= TRUE;
+    }
+    if(isset($_POST['menu_dialog_refresh'])){
+      $this->show_details= FALSE;
+    }
+
+    if(isset($_POST['migrate_menus'])){
+      $this->migrate_menus();
+#      $this->dialog = FALSE;
+ #     $this->show_details = FALSE;
+  #    $this->menu_dialog = FALSE;
+   #   $this->initialize_checks();
+    }
+
+    if(isset($_POST['menu_dialog'])){
+      $this->menu_dialog = TRUE;
+      $this->dialog = TRUE;
+    }
+    
+    if($this->menu_dialog){
+      $smarty = get_smarty();
+      $smarty->assign("method","menus");
+      $smarty->assign("menus",$this->menu);
+      $smarty->assign("menu_details", $this->show_details);
+      return($smarty->fetch(get_template_path("setup_migrate.tpl",TRUE,dirname(__FILE__))));
+    }
+
     $smarty = get_smarty();
     $smarty->assign("checks",$this->checks);
     $smarty->assign("method","default");
@@ -1586,19 +1793,21 @@ class Step_Migrate extends setup_step
    */
   function checkBase($just_check = TRUE)
   {
-    /* Get collected setup informations */
-    $cv = $this->parent->captured_values;
-
     /* Establish ldap connection */
-    $ldap = new LDAP($cv['admin'],
+    $cv = $this->parent->captured_values;
+    $ldap_l = new LDAP($cv['admin'],
         $cv['password'],
         $cv['connection'],
         FALSE,
         $cv['tls']);
 
+    $ldap = new ldapMultiplexer($ldap_l);
+
     /* Check if root object exists */
     $ldap->cd($cv['base']);
+    $ldap->set_size_limit(1);
     $res = $ldap->search("(objectClass=*)");
+    $ldap->set_size_limit(0);
     $err = ldap_errno($ldap->cid); 
 
     if( !$res || 
@@ -1663,16 +1872,15 @@ class Step_Migrate extends setup_step
 
   function get_user_list()
   {
-    /* Get collected configuration settings */
-    $cv = $this->parent->captured_values;
-
     /* Establish ldap connection */
-    $ldap = new LDAP($cv['admin'],
+    $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']);
     $ldap->search("(objectClass=gosaAccount)",array("dn"));
   
@@ -1691,12 +1899,14 @@ class Step_Migrate extends setup_step
     $people_ou = trim($cv['peopleou']);
 
     /* Establish ldap connection */
-    $ldap = new LDAP($cv['admin'],
+    $cv = $this->parent->captured_values;
+    $ldap_l = new LDAP($cv['admin'],
         $cv['password'],
         $cv['connection'],
         FALSE,
         $cv['tls']);
 
+    $ldap = new ldapMultiplexer($ldap_l);
 
     /*****************
      * If people ou is NOT empty
@@ -1747,19 +1957,19 @@ class Step_Migrate extends setup_step
 
   function get_all_winstation_ous()
   {
-    /* Get collected configuration settings */
-    $cv = $this->parent->captured_values;
-
     /* Establish ldap connection */
-    $ldap = new LDAP($cv['admin'],
+    $cv = $this->parent->captured_values;
+    $ldap_l = new LDAP($cv['admin'],
         $cv['password'],
         $cv['connection'],
         FALSE,
         $cv['tls']);
 
+    $ldap = new ldapMultiplexer($ldap_l);
+
     /* Get winstation ou */
     if($cv['generic_settings']['wws_ou_active']) {
-      $winstation_ou = $cv['generic_settings']['ws_ou'];
+      $winstation_ou = $cv['generic_settings']['wws_ou'];
     }else{
       $winstation_ou = "ou=winstations";
     }
@@ -1794,16 +2004,16 @@ class Step_Migrate extends setup_step
 
  function get_all_group_ous()
   {
-    /* Get collected configuration settings */
-    $cv = $this->parent->captured_values;
-
     /* Establish ldap connection */
-    $ldap = new LDAP($cv['admin'],
+    $cv = $this->parent->captured_values;
+    $ldap_l = new LDAP($cv['admin'],
         $cv['password'],
         $cv['connection'],
         FALSE,
         $cv['tls']);
 
+    $ldap = new ldapMultiplexer($ldap_l);
+
     $group_ou = trim($cv['groupou']);
     if(!empty($group_ou)){
       $group_ou = trim($group_ou);
@@ -1855,15 +2065,15 @@ class Step_Migrate extends setup_step
 
   function get_group_list()
   {
-    /* Get collected configuration settings */
-    $cv = $this->parent->captured_values;
-
     /* Establish ldap connection */
-    $ldap = new LDAP($cv['admin'],
+    $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']);
     $ldap->search("(objectClass=posixGroup)",array("dn"));
@@ -1878,16 +2088,16 @@ class Step_Migrate extends setup_step
 
   function move($source,$destination)
   {
-    /* Get collected configuration settings */
-    $cv = $this->parent->captured_values;
-
     /* Establish ldap connection */
-    $ldap = new LDAP($cv['admin'],
+    $cv = $this->parent->captured_values;
+    $ldap_l = new LDAP($cv['admin'],
         $cv['password'],
         $cv['connection'],
         FALSE,
         $cv['tls']);
 
+    $ldap = new ldapMultiplexer($ldap_l);
+
      /* Update object references in gosaGroupOfNames */
     $ogs_to_fix = array();
     $ldap->cd($cv['base']);
@@ -1928,7 +2138,7 @@ class Step_Migrate extends setup_step
     }
   }
 
-  
+
   /* Cleanup ldap result to be able to write it be to ldap */
   function cleanup_array($attrs)
   {
@@ -1942,6 +2152,687 @@ class Step_Migrate extends setup_step
     }
     return($attrs);
   }
+
+
+  /*! \brief  Act in posts from the device migration dialog 
+   */
+  function check_device_posts()
+  {
+    foreach($this->device as $key => $device){
+      if(isset($_POST["migrate_".$key])){
+        $this->device[$key]['DETAILS'] =TRUE;
+      }else{
+        $this->device[$key]['DETAILS'] =FALSE;
+      }
+    }
+  }
+
+
+  /*! \brief  Check for old style (gosa-2.5) devices.
+              Save readable informations and a list of migratable devices 
+               in $this->devices.
+   */
+  function check_usb_devices ()
+  {
+    /* 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']);
+    $res = $ldap->search("(&(|(objectClass=posixAccount)(objectClass=posixGroup))(gotoHotplugDevice=*))",
+        array("cn","gotoHotplugDevice","gosaUnitTag"));
+
+    if(!$res){
+      $this->checks['old_style_devices']['STATUS']    = FALSE;
+      $this->checks['old_style_devices']['STATUS_MSG']= _("LDAP query failed");
+      $this->checks['old_style_devices']['ERROR_MSG'] = _("Possibly the 'root object' is missing.");
+      return;
+    }
+
+
+    /* If adding failed, tell the user */
+    if($ldap->count()){
+  
+      $this->device = array();
+      while($attrs = $ldap->fetch()){
+
+        for ($j= 0; $j < $attrs['gotoHotplugDevice']['count']; $j++){
+
+          $after  = "";
+          $current= "";
+
+          $entry= $attrs['gotoHotplugDevice'][$j];
+
+          @list($name,$desc,$serial,$vendor,$product) = explode('|', $entry);
+  
+          $add = 1;
+          $new_name  = $name;
+          while(isset($dest[$new_name])){
+            $new_name = $name."_".$add;
+            $add ++;
+          }
+          $name = $new_name;
+          $newdn= "cn=$name,ou=devices,".preg_replace('/^[^,]+,/', '', $attrs['dn']);
+
+          if (!isset($dest[$name])){
+            $dest[$name]= $newdn;
+
+            $current.= "dn: ".$attrs['dn']."\n"; 
+    
+            for ($c= 0; $c < $attrs['gotoHotplugDevice']['count']; $c++){
+              if($c == $j){
+                $current.= "<b>gotoHotplugDevice: ".$attrs['gotoHotplugDevice'][$c]."</b>\n"; 
+              }else{
+                $current.= "gotoHotplugDevice: ".$attrs['gotoHotplugDevice'][$c]."\n"; 
+              }
+            }
+
+            $after.= "dn: $newdn\n";
+            $after.= "changetype: add\n";
+            $after.= "objectClass: top\n";
+            $after.= "objectClass: gotoDevice\n";
+            if (isset($attrs['gosaunittag'][0])){
+              $after.= "objectClass: gosaAdminiafter\n";
+              $after.= "gosaUnitTag: ".$attrs['gosaunittag'][0]."\n";
+            }
+            $after.= "cn: $name\n";
+            $after.= "gotoHotplugDevice: $desc|$serial|$vendor|$product\n\n";
+
+            $this->device[] = array(
+                'CURRENT'     =>  $current,
+                'AFTER'       => $after,
+                'OLD_DEVICE'  => $entry,
+                'DN'          => $attrs['dn'],
+                'NEW_DN'      => $newdn,
+                'DEVICE_NAME' => $name,
+                'DETAILS'     => FALSE);
+          }
+        }
+      }
+
+      $this->checks['old_style_devices']['STATUS']    = FALSE;
+      $this->checks['old_style_devices']['STATUS_MSG']= "<font style='color:#F0A500'>"._("Warning")."</font>";
+      $this->checks['old_style_devices']['ERROR_MSG'] = 
+        sprintf(_("There are %s devices that need to be migrated."),count($this->device)).
+          "<input type='submit' name='device_dialog' value='"._("Migrate")."'>";
+    }else{
+      $this->checks['old_style_devices']['STATUS']    = TRUE;
+      $this->checks['old_style_devices']['STATUS_MSG']= _("Ok");
+      $this->checks['old_style_devices']['ERROR_MSG'] = "";
+    }
+  }
+
+
+  /*! \brief  Migrate all selected devices. 
+              Execute all required ldap actions to migrate the 
+               selected devices.
+   */
+  function migrate_usb_devices ()
+  {
+    /* 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);
+
+    /* Walk through migrateable devices and initiate migration for all 
+        devices that are checked (DETAILS==TRUE) 
+     */
+    foreach($this->device as $key => $device){
+      if($device['DETAILS']){
+
+        /* Get source object and verify that the specified device is a 
+            member attribute of it. 
+         */
+        $ldap->cd($cv['base']);
+        $ldap->cat($device['DN']);
+        $attrs = $ldap->fetch();
+        if(in_array($device['OLD_DEVICE'],$attrs['gotoHotplugDevice'])){
+
+          /* Create new hotplug device object 'gotoDevice'
+           */ 
+          @list($name,$desc,$serial,$vendor,$product) = explode('|', $device['OLD_DEVICE']);    
+          $newdn = $device['NEW_DN'];
+          $new_attr = array();
+          $new_attr['cn'] = $device['DEVICE_NAME'];
+          $new_attr['objectClass'] = array('top','gotoDevice');
+          $new_attr['gotoHotplugDevice'] = "$desc|$serial|$vendor|$product";
+
+          /* Add new object 
+           */
+          $ldap->cd($cv['base']);
+          $ldap->create_missing_trees(preg_replace("/^[^,]+,/","",$newdn));
+          $ldap->cd($newdn);
+          $ldap->add($new_attr);
+
+          /* Throw an error message if the action failed. 
+           */
+          if(!$ldap->success()){
+            msg_dialog::display(_("LDAP error"), 
+                sprintf(_("Adding '%s' to the LDAP failed: %s"),
+                  "<b>".LDAP::fix($newdn)."</b>", 
+                  "<br><br><i>".$ldap->get_error()."</i>"), ERROR_DIALOG);
+          }else{
+
+            /* Remove old style device definition from source object. 
+             */
+            $update['gotoHotplugDevice'] = array();
+            for($i = 0 ; $i < $attrs['gotoHotplugDevice']['count'] ; $i++){
+              if($attrs['gotoHotplugDevice'][$i] == $device['OLD_DEVICE']){
+                 continue;
+              }
+              $update['gotoHotplugDevice'][] = $attrs['gotoHotplugDevice'][$i];
+            }
+
+            $ldap->cd($device['DN']);
+            $ldap->modify($update);
+            $ldap->cat($device['DN'],array("gotoHotplugDevice"));
+            if(!$ldap->success()){
+              msg_dialog::display(_("LDAP error"), 
+                  sprintf(_("Updating '%s' failed: %s"),
+                    "<b>".LDAP::fix($device['DN'])."</b>", 
+                    "<br><br><i>".$ldap->get_error()."</b>"), ERROR_DIALOG);
+            }else{
+              unset($this->device[$key]);
+            }
+          }
+        }
+      }
+    }
+    $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 */
+    $cv = $this->parent->captured_values;
+    $ldap_l = new LDAP($cv['admin'],
+        $cv['password'],
+        $cv['connection'],
+        FALSE,
+        $cv['tls']);
+
+    $ldap = new ldapMultiplexer($ldap_l);
+    $this->service = array();
+
+    /* Check for Ldap services that must be migrated 
+     */ 
+    $ldap->cd($cv['base']);
+    $res = $ldap->search("(objectClass=goLdapServer)", array("goLdapBase", "cn"));
+
+    /* Check if we were able to query the ldap server 
+     */
+    if(!$res){
+      $this->checks['old_style_services']['STATUS']    = FALSE;
+      $this->checks['old_style_services']['STATUS_MSG']= _("LDAP query failed");
+      $this->checks['old_style_services']['ERROR_MSG'] = _("Possibly the 'root object' is missing.");
+      return;
+    }
+
+    /* Walk through each configured ldap server 
+        and check if it is configured correctly.
+     */
+    while($attrs = $ldap->fetch()){
+      $dn= $attrs['dn'];
+      $uri= $attrs['goLdapBase'][0];
+      if (! preg_match("!^ldaps?://!", $uri)){
+        $this->service[] = array(
+            "TYPE"    => "modify" , 
+            "DN"      => $dn, 
+            "DETAILS" => FALSE, 
+            "ATTRS"   => array("goLdapBase" => "ldap://".$attrs['cn'][0]."/$uri"),
+            "CURRENT" => "goLdapBase: ".$uri,
+            "AFTER"   => "goLdapBase: "."ldap://".$attrs['cn'][0]."/$uri");
+      }
+    }
+
+    /* Other sevices following here later ...maybe
+     */
+
+    /*  Update status message
+     */
+    if(count($this->service)){
+      $this->checks['old_style_services']['STATUS']    = FALSE;
+      $this->checks['old_style_services']['STATUS_MSG']= "<font style='color:#F0A500'>"._("Warning")."</font>";
+      $this->checks['old_style_services']['ERROR_MSG'] =
+        sprintf(_("There are %s services that need to be migrated."),
+            count($this->service)).
+        "<input type='submit' name='service_dialog' value='"._("Migrate")."'>";
+    }else{
+      $this->checks['old_style_services']['STATUS']    = TRUE;
+      $this->checks['old_style_services']['STATUS_MSG']= _("Ok");
+      $this->checks['old_style_services']['ERROR_MSG'] = "";
+    }
+  }
+
+
+  
+  /*! \brief  Migrate selected services.
+              This function executes the commands collected by the 
+               service_check() function.
+   */
+  function migrate_services()
+  {
+    /* 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);
+
+    /* Handle each service 
+     */
+    foreach($this->service as $key => $service){
+      if($service['DETAILS']){
+
+        /* Handle modify requests 
+         */
+        if($service['TYPE'] == "modify"){
+          $ldap->cd($service['DN']);
+          $ldap->modify($service['ATTRS']);
+
+          /* Check if everything done was successful 
+           */
+          if(!$ldap->success()){
+            msg_dialog::display(_("LDAP error"), 
+                sprintf(_("Updating '%s' failed: %s"),
+                  "<b>".LDAP::fix($service['DN'])."</b>", 
+                  "<br><br><i>".$ldap->get_error()."</b>"), ERROR_DIALOG);
+          }else{
+        
+            /* Remove action from list 
+             */
+            unset($this->service[$key]);
+          }
+        }
+      }
+    }
+
+    /* 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){
+      if(isset($_POST["migrate_".$key])){
+        $this->service[$key]['DETAILS'] =TRUE;
+      }else{
+        $this->service[$key]['DETAILS'] =FALSE;
+      }
+    }
+  }
+
+
+  /*! \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()
+  {
+    /* 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);
+
+    /* First detect all release names 
+     */
+    $ldap->cd($cv['base']);
+    $res = $ldap->search("(&(objectClass=organizational)(objectClass=FAIbranch))",array("ou","objectClass"));
+
+    /* Check if we were able to query the ldap server
+     */
+    if(!$res){
+      $this->checks['old_style_menus']['STATUS']    = FALSE;
+      $this->checks['old_style_menus']['STATUS_MSG']= _("LDAP query failed");
+      $this->checks['old_style_menus']['ERROR_MSG'] = _("Possibly the 'root object' is missing.");
+      return;
+    }
+
+    /* 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()){
+      if (isset($info['gosaApplicationParameter']['count'])){
+        for ($j= 0; $j < $info['gosaApplicationParameter']['count']; $j++){
+          $p= preg_replace("/^([^:]+):.*$/", "$1", $info['gosaApplicationParameter'][$j]);
+
+          if(!isset($amap[$info['cn'][0]]) || !in_array($p, $amap[$info['cn'][0]])){
+            $amap[$info['cn'][0]][]= $p;
+          }
+        }
+      } else {
+        $amap[$info['cn'][0]]= array();
+      }
+    }
+
+    /* 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","gosaUnitTag"));
+
+    /* Create readable prefix for "What will be done" infos 
+     */
+    $s_add = "<i>"._("Add")."</i>\t";
+    $s_del = "<i>"._("Remove")."</i>\t";
+
+    /* Walk through all found old-style menu configurations.
+        -Prepare ldap update list     $data   
+        -Prepare printable changes    $after/$current
+     */
+    while($info = $ldap->fetch()){
+
+      $data = array();
+      $current = "";
+      $after ="";
+
+      /* Get unit tag 
+       */
+      $tag ="";
+      if(isset($info['gosaUnitTag'])){
+        $tag = $info['gosaUnitTag'][0];
+      }
+
+      /* Collect application parameter for this group
+       */
+      $params= array();
+      if(isset($info['gosaApplicationParameter'])){
+        for ($i= 0; $i < $info['gosaApplicationParameter']['count']; $i++){
+          $name= preg_replace("/^([^:]+):.*$/", "$1", $info['gosaApplicationParameter'][$i]);
+          $params[$name]= $info['gosaApplicationParameter'][$i];
+        }
+      }
+
+      /* 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);
+      foreach($z as $part){
+
+        if(!empty($part)){
+          $release = "ou=".$part.",".$release;
+
+          /* Append release department information to "What will be done" info
+           */
+          $release_dn = $release.$info['dn'];
+          $after   .=  $s_add."dn: $release_dn\n";
+          $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";
+
+          /* 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;
+        }
+      }
+
+      /* Add member applications to the array.
+       */ 
+      $current .= "dn: ".$info['dn']."\n";
+      $menu_structure = array();
+      for ($i= 0; $i < $info['gosaMemberApplication']['count']; $i++){
+        list($name, $location, $priority)= explode("|", $info['gosaMemberApplication'][$i]);
+
+        /* Create location dn 
+         */
+        $location_dn ="";
+        if(!empty($location)){
+          $location_dn ="cn=".$location.",";
+        }
+
+        /* Append old style element to current detail informations 
+         */      
+        $current .= $s_del."gosaMemberApplication: ".$info['gosaMemberApplication'][$i]."\n";
+
+        /* Append ldap update action to remove the old menu entry attributes 
+         */
+        unset($info['objectClass']['count']);
+        $d = array();
+        $d['gosaMemberApplication']      = array();
+        $d['gosaApplicationParameter']  = array();
+        if(isset($info['FAIrelease'])){
+          $d['FAIrelease'] = array();
+        }
+        $d['objectClass']               = array_remove_entries(array("gosaApplicationGroup","FAIreleaseTag"),$info['objectClass']);
+        $data['MODIFY'][$info['dn']]    = $d;
+
+        /* Create new application menu structure 
+         */
+        if (isset($amap[$name])){
+
+          /* Append missing menu structure to "What is done info"
+           */
+          if(!isset($menu_structure[$location]) && !empty($location)){
+            $menu_structure[$location] = TRUE;
+            $after .= "\n";
+            $after .= $s_add."dn: $location_dn$release_dn\n";
+            $after .= $s_add."objectClass: gotoSubmenuEntry\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 for "What is done info".
+           */
+          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;
+
+            foreach ($amap[$name] as $n){
+              if (isset($params[$n])){
+                $after .= $s_add."gosaApplicationParameter: ".$params[$n]."\n";
+                $d['gosaApplicationParameter'][] = $params[$n];
+              }
+            }
+            $data['ADD']["cn=$name,$location_dn$release_dn"] = $d;
+          }         
+        }
+      }
+
+      /* Updated todo list 
+       */ 
+      $todo[] = array(
+          "DETAILS" => FALSE,
+          "DN"      => $info['dn'],
+          "AFTER"   => $after,
+          "CURRENT" => $current,
+          "TODO"    => $data
+          );
+    }
+
+    /* Remember checks.
+     */
+    $this->menu = $todo;
+
+    /* Check if we were able to query the ldap server
+     */
+    if(count($this->menu)){
+      $this->checks['old_style_menus']['STATUS']    = FALSE;
+      $this->checks['old_style_menus']['STATUS_MSG']= "<font style='color:#F0A500'>"._("Warning")."</font>";
+      $this->checks['old_style_menus']['ERROR_MSG'] = sprintf(_("There are %s application menus which have to be migrated."),
+                                                      count($this->menu))."<input type='submit' name='menu_dialog' value='"._("Migrate")."'>";
+    }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){
+      if(isset($_POST["migrate_".$key])){
+        $this->menu[$key]['DETAILS'] =TRUE;
+      }else{
+        $this->menu[$key]['DETAILS'] =FALSE;
+      }
+    }
+  }
+
+
+  /*! \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
+     */
+    $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']);
+
+    /* 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']);
+          if(!$ldap->dn_exists($dn)){
+            $ldap->cd($dn);
+            $ldap->add($data);
+            if (!$ldap->success()){
+              msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $dn, LDAP_ADD, get_class()));
+              $success = FALSE;
+            }
+          }
+        }
+
+        /* Execute all LDAP-MODIFY actions 
+         */
+        foreach($menu['TODO']['MODIFY'] as $dn => $data){
+          $ldap->cd($cv['base']);
+          if($ldap->dn_exists($dn)){
+            $ldap->cd($dn);
+            $ldap->modify($data);
+            if (!$ldap->success()){
+              msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $dn, LDAP_MOD, get_class()));
+              $success = FALSE;
+            }
+          }
+        }
+  
+        /* 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();
+  }
 }
 
 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: