Index: trunk/contactcenter/inc/class.bo_ldap_manager.inc.php
===================================================================
--- trunk/contactcenter/inc/class.bo_ldap_manager.inc.php	(revision 285)
+++ trunk/contactcenter/inc/class.bo_ldap_manager.inc.php	(revision 314)
@@ -249,5 +249,5 @@
 			}
 			
-			$ldap = $GLOBALS['phpgw']->common->ldapConnect($this->srcs[$id_source]['host'], $this->srcs[$id_source]['acc'],$this->srcs[$id_source]['pw'], false);
+			$ldap = $GLOBALS['phpgw']->common->ldapConnect($this->srcs[$id_source]['host'], $this->srcs[$id_source]['acc'],$this->srcs[$id_source]['pw'], true);
 			if (!$ldap)
 			{
@@ -410,4 +410,6 @@
 			else 
 				return false;
+			
+			
 		}
 
@@ -447,16 +449,10 @@
 		function get_ldap_tree_level($id_source, $resource, $context, $objectClass, $branch_dn, $external = 0)
 		{
-			if(strstr($context, "ldap://")){
-				$refer_context = str_replace("??base","",preg_replace('!^(ldap://[^/]+)/(.*$)!', '\\2', $context));
-				$host	= preg_replace('!^(ldap://[^/]+)/.*$!', '\\1', $context);
-				$resource = ldap_connect($host);
-				ldap_bind($resource);
-			}
-
+						
 			/*
 			 * TODO: Search timeouts
 			 */
-
-			$dn_parts = ldap_explode_dn(($refer_context ? $refer_context : $context),1);
+			
+			$dn_parts = ldap_explode_dn($context,1);
 			//$filter = '(!(objectClass='.$objectClass.'))';
 			// Don't show OU's whith phpgwAccountVisible equal to '-1'
@@ -472,7 +468,7 @@
 				$filter = '(&(!(objectClass='.$objectClass.')) (!(phpgwAccountVisible=-1)))';
 			}
-			$result_res = @ldap_list($resource,  ($refer_context ? $refer_context : $context), $filter, array(), 0, 0);
+			$result_res = @ldap_list($resource,  $context, $filter, array(), 0, 0);
 			@ldap_sort($resource, $result_res, 'ou');
-
+			
 			// Timeouts commented out
 			/*
@@ -484,10 +480,10 @@
 
 			$count = ldap_count_entries($resource,$result_res);
-
+			
 			if ( $count == 0 )
 			{
 				$filter = '(objectClass='.$objectClass.')';
 				// Get only one attribute of the source's objectClass
-				$result_res2 = @ldap_list($resource, ($refer_context ? $refer_context : $context), $filter, Array('cn'), 0, 1);
+				$result_res2 = @ldap_list($resource, $context, $filter, Array('cn'), 0, 1);
 				$entries_count = ldap_count_entries($resource, $result_res2);
 
@@ -513,5 +509,5 @@
 				}
 			}
-
+			
 			$sub_branch_found = false;
 			$i = 0;
@@ -531,5 +527,5 @@
 						'name'  => $this->translate_accentuation($dn_parts_1[0]),
 						'type'  => 'unknown',
-						'value' =>  ($refer_context ? $host."/" : "").$dn,
+						'value' =>  $dn,
 						'sub_branch' => false
 					);
@@ -538,14 +534,7 @@
 				$i++;
 			}
-
-			if(! $refer_context) {
-				$array_referral = $this -> get_ldap_sub_branches_referrals($resource, $context,'(objectClass=organizationalUnit)');
-				for($z = 0; $z < count($array_referral); $z++) {
-					$tree['sub_branch'][$i++] = $array_referral[$z];
-				}
-			}
-
+						
 			$filter = 'objectClass='.$objectClass;
-			$result_res2 = @ldap_list($resource, ($refer_context ? $refer_context : $context), $filter, Array('cn'), 0, 1);
+			$result_res2 = @ldap_list($resource, $context, $filter, Array('cn'), 0, 1);
 			$entries_count = ldap_count_entries($resource, $result_res2);
 
Index: trunk/contactcenter/inc/class.bo_global_ldap_catalog.inc.php
===================================================================
--- trunk/contactcenter/inc/class.bo_global_ldap_catalog.inc.php	(revision 285)
+++ trunk/contactcenter/inc/class.bo_global_ldap_catalog.inc.php	(revision 314)
@@ -133,17 +133,9 @@
 			$filter = $this->process_restrictions($rules, $trans_f);
 
-			if(strstr($this->src_info['context'], "ldap://")) {
-				$refer_context 	= str_replace("??base","",preg_replace('!^(ldap://[^/]+)/(.*$)!', '\\2', $this->src_info['context']));
-				$host	= preg_replace('!^(ldap://[^/]+)/.*$!', '\\1', $this->src_info['context']);				
-				$this->src_info['host'] = $host;
-			}			
-
-			if($refer_context || "ou" === strtolower(substr($this->src_info['context'], 0, 2)))
-			{		
-				$followReferral = false;			
-			}
-			elseif(trim($rules[4]['value']) != "inetOrgPerson")	
+			if("ou" === strtolower(substr($this->src_info['context'], 0, 2)) ||
+				(trim($rules[4]['value']) != "inetOrgPerson"))	
 			{			
-				$followReferral = true;
+				$ldap = $GLOBALS['phpgw']->common->ldapConnect($this->src_info['host'], $this->src_info['acc'], $this->src_info['pw'], true);
+				$result_r = ldap_search($ldap , $this->src_info['context'], $filter, $fields, 0);
 			}
 			else
@@ -152,6 +144,4 @@
 			}
 			
-			$ldap = $GLOBALS['phpgw']->common->ldapConnect($this->src_info['host'], $this->src_info['acc'], $this->src_info['pw'], $followReferral);
-			$result_r = ldap_search($ldap ,($refer_context  ? $refer_context  : $this->src_info['context']), $filter, $fields, 0);
 
 			if (!$result_r)
@@ -570,6 +560,6 @@
 			}
 			
-			$resource = ldap_read($ldap, $id_contact, 'objectClass='.$this->src_info['obj']);
-			$n_entries = ldap_count_entries($ldap, $resource);
+			$resource = @ldap_read($ldap, $id_contact, 'objectClass='.$this->src_info['obj']);
+			$n_entries = @ldap_count_entries($ldap, $resource);
 			if ( $n_entries > 1 or $n_entries < 1)
 			{
