Code

Updated class_config
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 5 Mar 2008 08:58:18 +0000 (08:58 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 5 Mar 2008 08:58:18 +0000 (08:58 +0000)
-get_ldap_link() checks now, if the current ldap link still valid, if not it creates a new one.

git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@9337 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-core/include/class_config.inc

index 274142b83de9735d769a8a36ddc3e016d56ae793..9ade720a7bcc97c1dc754e2a436ab35af2826f07 100644 (file)
@@ -216,35 +216,37 @@ class config  {
 
   function get_ldap_link($sizelimit= FALSE)
   {
-    /* Build new connection */
-    $this->ldap= ldap_init ($this->current['SERVER'], $this->current['BASE'],
-        $this->current['ADMIN'], $this->current['PASSWORD']);
+    if(!is_resource($this->ldap->cid)){
 
-    /* Check for connection */
-    if (is_null($this->ldap) || (is_int($this->ldap) && $this->ldap == 0)){
-      $smarty= get_smarty();
-      msg_dialog::display(_("LDAP error"), _("Cannot bind to LDAP. Please contact the system administrator."), FATAL_ERROR_DIALOG);
-      exit();
-    }
+      /* Build new connection */
+      $this->ldap= ldap_init ($this->current['SERVER'], $this->current['BASE'],
+          $this->current['ADMIN'], $this->current['PASSWORD']);
 
-    if (!session::is_set('size_limit')){
-      session::set('size_limit',$this->current['SIZELIMIT']);
-      session::set('size_ignore',$this->current['SIZEIGNORE']);
-    }
+      /* Check for connection */
+      if (is_null($this->ldap) || (is_int($this->ldap) && $this->ldap == 0)){
+        $smarty= get_smarty();
+        msg_dialog::display(_("LDAP error"), _("Cannot bind to LDAP. Please contact the system administrator."), FATAL_ERROR_DIALOG);
+        exit();
+      }
 
-    if ($sizelimit){
-      $this->ldap->set_size_limit(session::get('size_limit'));
-    } else {
-      $this->ldap->set_size_limit(0);
-    }
+      if (!session::is_set('size_limit')){
+        session::set('size_limit',$this->current['SIZELIMIT']);
+        session::set('size_ignore',$this->current['SIZEIGNORE']);
+      }
 
-    /* Move referrals */
-    if (!isset($this->current['REFERRAL'])){
-      $this->ldap->referrals= array();
-    } else {
-      $this->ldap->referrals= $this->current['REFERRAL'];
-    }
+      if ($sizelimit){
+        $this->ldap->set_size_limit(session::get('size_limit'));
+      } else {
+        $this->ldap->set_size_limit(0);
+      }
 
+      /* Move referrals */
+      if (!isset($this->current['REFERRAL'])){
+        $this->ldap->referrals= array();
+      } else {
+        $this->ldap->referrals= $this->current['REFERRAL'];
+      }
+    }
     return ($this->ldap);
   }