Code

Updated class_config
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 5 Mar 2008 08:57:19 +0000 (08:57 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 5 Mar 2008 08:57:19 +0000 (08:57 +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/branches/2.5@9336 594d385d-05f5-0310-b6e9-bd551577e9d8

include/class_config.inc

index 848bc57a28ea351822da34d7dd17a403eacee999..209d1f83ab055dc834cdd9412ff6142f0a7bb0ff 100644 (file)
@@ -181,37 +181,40 @@ 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']);
 
-    /* Check for connection */
-    if (is_null($this->ldap) || (is_int($this->ldap) && $this->ldap == 0)){
-      $smarty= get_smarty();
-      print_red (_("Can't bind to LDAP. Please contact the system administrator."));
-      $smarty->display (get_template_path('headers.tpl'));
-      echo '<body style="background-image:none">'.$_SESSION['errors'].'</body></html>';
-      exit();
-    }
+    if(!is_resource($this->ldap->cid)){
 
-    if (!isset($_SESSION['size_limit'])){
-      $_SESSION['size_limit']= $this->current['SIZELIMIT'];
-      $_SESSION['size_ignore']= $this->current['SIZEIGNORE'];
-    }
+      /* Build new connection */
+      $this->ldap= ldap_init ($this->current['SERVER'], $this->current['BASE'],
+          $this->current['ADMIN'], $this->current['PASSWORD']);
 
-    if ($sizelimit){
-      $this->ldap->set_size_limit($_SESSION['size_limit']);
-    } else {
-      $this->ldap->set_size_limit(0);
-    }
+      /* Check for connection */
+      if (is_null($this->ldap) || (is_int($this->ldap) && $this->ldap == 0)){
+        $smarty= get_smarty();
+        print_red (_("Can't bind to LDAP. Please contact the system administrator."));
+        $smarty->display (get_template_path('headers.tpl'));
+        echo '<body style="background-image:none">'.$_SESSION['errors'].'</body></html>';
+        exit();
+      }
 
-    /* Move referrals */
-    if (!isset($this->current['REFERRAL'])){
-      $this->ldap->referrals= array();
-    } else {
-      $this->ldap->referrals= $this->current['REFERRAL'];
-    }
+      if (!isset($_SESSION['size_limit'])){
+        $_SESSION['size_limit']= $this->current['SIZELIMIT'];
+        $_SESSION['size_ignore']= $this->current['SIZEIGNORE'];
+      }
+
+      if ($sizelimit){
+        $this->ldap->set_size_limit($_SESSION['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);
   }