diff --git a/html/main.php b/html/main.php
index 280d327f6a25c1950199a9a020782ada269260e0..07b69e40c6a5ea5aabb39cc83ccab2f42376e744 100644
--- a/html/main.php
+++ b/html/main.php
@@ -194,7 +194,7 @@ if ($old_plugin_dir != $plugin_dir && $old_plugin_dir != "") {
 }
 
 /* Check for sizelimits */
-eval_sizelimit();
+$ui->getSizeLimitHandler()->update();
 
 /* Check for memory */
 if (memory_get_usage() > (to_byte(ini_get('memory_limit')) - 2048000 )) {
diff --git a/include/class_config.inc b/include/class_config.inc
index 19792382548348a1e36bcdbba23f984659f835c9..ee7cb0fb488ef65239edc048b42f71b3f00a4022 100644
--- a/include/class_config.inc
+++ b/include/class_config.inc
@@ -308,8 +308,9 @@ class config
    */
   function get_ldap_link($sizelimit = FALSE)
   {
-    if ($this->ldapLink === NULL || !is_resource($this->ldapLink->cid)) {
+    global $ui;
 
+    if ($this->ldapLink === NULL || !is_resource($this->ldapLink->cid)) {
       /* Build new connection */
       $this->ldapLink = ldap_init ($this->current['SERVER'], $this->current['BASE'],
           $this->current['ADMINDN'], $this->get_credentials($this->current['ADMINPASSWORD']));
@@ -326,16 +327,11 @@ class config
       } else {
         $this->ldapLink->referrals = $this->current['REFERRAL'];
       }
-
-      if (!session::global_is_set('size_limit')) {
-        session::global_set('size_limit',   $this->current['LDAPSIZELIMIT']);
-        session::global_set('size_ignore',  preg_match('/true/i', $this->current['LDAPSIZEIGNORE']));
-      }
     }
 
     $obj  = new ldapMultiplexer($this->ldapLink);
     if ($sizelimit) {
-      $obj->set_size_limit(session::global_get('size_limit'));
+      $obj->set_size_limit($ui->getSizeLimitHandler()->getSizeLimit());
     } else {
       $obj->set_size_limit(0);
     }
@@ -381,20 +377,9 @@ class config
       $this->current['ADMINPASSWORD'] = $this->current['REFERRAL'][$this->current['SERVER']]['ADMINPASSWORD'];
     }
 
-    /* We need LDAPSIZELIMIT and LDAPSIZEIGNORE set before we connect to the ldap */
-    if (!isset($this->current['LDAPSIZELIMIT'])) {
-      $this->current['LDAPSIZELIMIT'] = 200;
-    }
-    if (!isset($this->current['LDAPSIZEIGNORE'])) {
-      $this->current['LDAPSIZEIGNORE'] = "TRUE";
-    }
-
     /* Load in-ldap configuration */
     $this->load_inldap_config();
 
-    /* We update LDAPSIZELIMIT as it may have been changed by ldap config */
-    session::global_set('size_limit', $this->current['LDAPSIZELIMIT']);
-
     if (class_available('systemManagement')) {
       /* Load server informations */
       $this->load_servers();
diff --git a/include/class_filterLDAP.inc b/include/class_filterLDAP.inc
index d22e349037c950d89ca618f2df66ebf5ba2646a6..3d41482cf9881641f6ed10c5c67b9a14b66611ee 100644
--- a/include/class_filterLDAP.inc
+++ b/include/class_filterLDAP.inc
@@ -141,7 +141,7 @@ class filterLDAP
 
       // Check for size limit exceeded messages for GUI feedback
       if (preg_match("/size limit/i", $ldap->get_error())) {
-        session::set('limit_exceeded', TRUE);
+        $ui->getSizeLimitHandler()->setLimitExceeded();
         $limit_exceeded = TRUE;
       }
 
diff --git a/include/class_ldapSizeLimit.inc b/include/class_ldapSizeLimit.inc
new file mode 100644
index 0000000000000000000000000000000000000000..01fe97de4b229babc8701017fbd11d5e98b57a89
--- /dev/null
+++ b/include/class_ldapSizeLimit.inc
@@ -0,0 +1,140 @@
+<?php
+/*
+  This code is part of FusionDirectory (http://www.fusiondirectory.org/)
+  Copyright (C) 2017-2018  FusionDirectory
+
+  This program is free software; you can redistribute it and/or modify
+  it under the terms of the GNU General Public License as published by
+  the Free Software Foundation; either version 2 of the License, or
+  (at your option) any later version.
+
+  This program is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  GNU General Public License for more details.
+
+  You should have received a copy of the GNU General Public License
+  along with this program; if not, write to the Free Software
+  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+*/
+
+/*!
+ * \file class_ldapSizeLimit.inc
+ * Source code for the class ldapSizeLimit
+ */
+
+/*!
+ * \brief Class ldapSizeLimit
+ * This class contains all informations and functions to handle the LDAP size limit dialogs, configuration and bypass
+ */
+
+class ldapSizeLimit
+{
+  /*! \brief Current size limit */
+  protected $sizeLimit;
+
+  /*! \brief Ignore dialogs */
+  protected $ignore;
+
+  /*! \brief Limit was exceeded */
+  protected $limitExceeded;
+
+  function __construct()
+  {
+    global $config;
+
+    $this->sizeLimit  = $config->get_cfg_value('LDAPSIZELIMIT', 200);
+    $this->ignore     = preg_match('/true/i', $config->get_cfg_value('LDAPSIZEIGNORE'));
+  }
+
+  function getSizeLimit()
+  {
+    return $this->sizeLimit;
+  }
+
+  function setSizeLimit($limit)
+  {
+    $this->sizeLimit = $limit;
+  }
+
+  function setLimitExceeded($exceeded = TRUE)
+  {
+    $this->limitExceeded = $exceeded;
+  }
+
+  /*!
+   * \brief Handle sizelimit dialog related posts
+   */
+  function update()
+  {
+    if (isset($_POST['set_size_action']) && isset($_POST['action'])) {
+      switch ($_POST['action']) {
+        case 'newlimit':
+          if (isset($_POST['new_limit']) && tests::is_id($_POST['new_limit'])) {
+            $this->sizeLimit  = intval($_POST['new_limit']);
+            $this->ignore     = FALSE;
+          }
+          break;
+        case 'ignore':
+          $this->sizeLimit  = 0;
+          $this->ignore     = TRUE;
+          break;
+        case 'limited':
+          $this->ignore     = TRUE;
+          break;
+        default:
+          break;
+      }
+    }
+
+    /* Allow fallback to dialog */
+    if (isset($_POST['edit_sizelimit'])) {
+      $this->ignore = FALSE;
+    }
+  }
+
+  /*!
+   * \brief Show sizelimit configuration dialog
+   *
+   * Show sizelimit configuration dialog when number
+   * of entries exceeded the sizelimit
+   */
+  function check()
+  {
+    global $config;
+
+    /* Ignore dialog? */
+    if ($this->ignore) {
+      return '';
+    }
+
+    /* Eventually show dialog */
+    if ($this->limitExceeded) {
+      $smarty = get_smarty();
+      $smarty->assign('warning', sprintf(_('The size limit of %d entries is exceed!'), $this->sizeLimit));
+      $smarty->assign('limit_message', sprintf(_('Set the new size limit to %s and show me this message if the limit still exceeds'), '<input type="text" name="new_limit" maxlength="10" size="5" value="'.($this->sizeLimit + 100).'"/>'));
+      return $smarty->fetch(get_template_path('sizelimit.tpl'));
+    }
+
+    return '';
+  }
+
+  /*!
+   * \brief Print a sizelimit warning
+   *
+   * Print a sizelimit warning when number
+   * of entries exceeded the sizelimit
+   */
+  function renderWarning()
+  {
+    if (($this->sizeLimit >= 10000000) || $this->limitExceeded) {
+      $config = '<input type="submit" name="edit_sizelimit" value="'._('Configure').'"/>';
+    } else {
+      $config = '';
+    }
+    if ($this->limitExceeded) {
+      return '('._('incomplete').") $config";
+    }
+    return '';
+  }
+}
diff --git a/include/class_listing.inc b/include/class_listing.inc
index 2908da4c4af0f39423cfe3bfaa8a76e607739c79..f08f89cf26b9d025e098fa59a72bc47a090f4b84 100644
--- a/include/class_listing.inc
+++ b/include/class_listing.inc
@@ -333,8 +333,10 @@ class listing
    */
   function render()
   {
+    global $ui;
+
     // Check for exeeded sizelimit
-    if (($message = check_sizelimit()) != '') {
+    if (($message = $ui->sizeLimitHandler()->check()) != '') {
       return $message;
     }
 
@@ -472,7 +474,7 @@ class listing
     $smarty = get_smarty();
     $smarty->assign("usePrototype", "true");
     $smarty->assign("FILTER", $this->filter->render());
-    $smarty->assign("SIZELIMIT", print_sizelimit_warning());
+    $smarty->assign("SIZELIMIT", $ui->sizeLimitHandler()->renderWarning());
     $smarty->assign("LIST", $result);
     $smarty->assign("MULTISELECT", $this->multiSelect);
 
@@ -1179,7 +1181,7 @@ class listing
    */
   function getAction()
   {
-    global $config;
+    global $config, $ui;
 
     // Do not do anything if this is not our PID, or there's even no PID available...
     if (!isset($_REQUEST['dn']) && (!isset($_REQUEST['PID']) || $_REQUEST['PID'] != $this->pid)) {
@@ -1224,11 +1226,11 @@ class listing
           $this->filter->setCurrentScope('one');
         }
         /* Bypass size limit just to be sure */
-        $oldsizelimit = session::global_get('size_limit');
-        session::global_set('size_limit', 0);
+        $oldsizelimit = $ui->getSizeLimitHandler()->getSizeLimit();
+        $ui->getSizeLimitHandler()->setSizeLimit(0);
         $this->update();
         $this->render();
-        session::global_set('size_limit', $oldsizelimit);
+        $ui->getSizeLimitHandler()->setSizeLimit($oldsizelimit);
         $this->filter->elementValues['NAME'] = '';
 
         $result['action']     = $action;
diff --git a/include/class_userinfo.inc b/include/class_userinfo.inc
index bc6243e227b3f16927aa1c555282524155946510..3b51fd6310d518624859b445ea20f676a49a7865 100644
--- a/include/class_userinfo.inc
+++ b/include/class_userinfo.inc
@@ -49,6 +49,9 @@ class userinfo
   var $ACLperPath             = array();
   var $ACLperPath_usesFilter  = array();
 
+  /*! \brief LDAP size limit handler */
+  protected $sizeLimitHandler;
+
   /* get acl's an put them into the userinfo object
      attr subtreeACL (userdn:components, userdn:component1#sub1#sub2,component2,...) */
   function __construct($userdn)
@@ -61,6 +64,8 @@ class userinfo
 
     /* Initialize ACL_CACHE */
     $this->reset_acl_cache();
+
+    $this->sizeLimitHandler = new ldapSizeLimit();
   }
 
   /*! \brief Loads user information from LDAP */
@@ -1016,5 +1021,10 @@ class userinfo
     }
     return FALSE;
   }
+
+  function getSizeLimitHandler()
+  {
+    return $this->sizeLimitHandler;
+  }
 }
 ?>
diff --git a/include/functions.inc b/include/functions.inc
index 85086dda6e440b357d6704d51a90c1186ba77fc2..41c9d0d4f2e698d6834d7ff9324929a4a8a382f9 100644
--- a/include/functions.inc
+++ b/include/functions.inc
@@ -808,83 +808,6 @@ function get_locks($objects, $allow_readonly = FALSE)
   return $locks;
 }
 
-/*!
- * \brief Show sizelimit configuration dialog
- *
- * Show sizelimit configuration dialog when number
- * of entries exceeded the sizelimit
- */
-function check_sizelimit()
-{
-  /* Ignore dialog? */
-  if (session::global_is_set('size_ignore') && session::global_get('size_ignore')) {
-    return '';
-  }
-
-  /* Eventually show dialog */
-  if (session::is_set('limit_exceeded') && session::get('limit_exceeded')) {
-    $smarty = get_smarty();
-    $smarty->assign('warning', sprintf(_('The size limit of %d entries is exceed!'),
-          session::global_get('size_limit')));
-    $smarty->assign('limit_message', sprintf(_('Set the new size limit to %s and show me this message if the limit still exceeds'), '<input type="text" name="new_limit" maxlength="10" size="5" value="'.(session::global_get('size_limit') + 100).'"/>'));
-    return $smarty->fetch(get_template_path('sizelimit.tpl'));
-  }
-
-  return '';
-}
-
-/*!
- * \brief Print a sizelimit warning
- *
- * Print a sizelimit warning when number
- * of entries exceeded the sizelimit
- */
-function print_sizelimit_warning()
-{
-  if (session::global_is_set('size_limit') && session::global_get('size_limit') >= 10000000 ||
-      (session::is_set('limit_exceeded') && session::get('limit_exceeded'))) {
-    $config = '<input type="submit" name="edit_sizelimit" value="'._('Configure').'"/>';
-  } else {
-    $config = '';
-  }
-  if (session::is_set('limit_exceeded') && session::get('limit_exceeded')) {
-    return '('._('incomplete').") $config";
-  }
-  return '';
-}
-
-
-/*!
- * \brief Handle sizelimit dialog related posts
- */
-function eval_sizelimit()
-{
-  if (isset($_POST['set_size_action']) && isset($_POST['action'])) {
-    switch ($_POST['action']) {
-      case 'newlimit':
-        if (isset($_POST['new_limit']) && tests::is_id($_POST['new_limit'])) {
-          session::global_set('size_limit', validate($_POST['new_limit']));
-          session::set('size_ignore', FALSE);
-        }
-        break;
-      case 'ignore':
-        session::global_set('size_limit', 0);
-        session::global_set('size_ignore', TRUE);
-        break;
-      case 'limited':
-        session::global_set('size_ignore', TRUE);
-        break;
-      default:
-        break;
-    }
-  }
-
-  /* Allow fallback to dialog */
-  if (isset($_POST['edit_sizelimit'])) {
-    session::global_set('size_ignore', FALSE);
-  }
-}
-
 /*!
  * \brief Return the current userinfo object
  *
diff --git a/include/management/class_management.inc b/include/management/class_management.inc
index 541dec5551918459039af5d80a96ce5f347b213a..b6b8b79755939dd6e96d269009ba09ae8492a306 100644
--- a/include/management/class_management.inc
+++ b/include/management/class_management.inc
@@ -420,7 +420,7 @@ class management
 
   function renderList()
   {
-    global $config;
+    global $config, $ui;
 
     // Rendering things using smarty themselves first
     $listRender   = $this->listing->render();
@@ -432,7 +432,7 @@ class management
     $smarty->assign('LIST',         $listRender);
     $smarty->assign('FILTER',       $filterRender);
     $smarty->assign('ACTIONS',      $actionMenu);
-    $smarty->assign('SIZELIMIT',    print_sizelimit_warning());
+    $smarty->assign('SIZELIMIT',    $ui->getSizeLimitHandler()->renderWarning());
     $smarty->assign('MULTISELECT',  $this->listing->multiSelect);
     $smarty->assign('NAVIGATION',   $this->listing->renderNavigation());
     $smarty->assign('BASE',         $this->listing->renderBase());
diff --git a/include/management/class_managementListing.inc b/include/management/class_managementListing.inc
index c287848bbddf6f406e86ae1c7eeba0bae1ea7370..4c304b3cce4cf3019e71a0590cff53e4a7dacb65 100644
--- a/include/management/class_managementListing.inc
+++ b/include/management/class_managementListing.inc
@@ -138,8 +138,10 @@ class managementListing
    */
   function render()
   {
+    global $ui;
+
     // Check for exeeded sizelimit
-    if (($message = check_sizelimit()) != '') {
+    if (($message = $ui->getSizeLimitHandler()->check()) != '') {
       return $message;
     }