Index: sandbox/webservice/api/json-rpc/Catalog.php
===================================================================
--- sandbox/webservice/api/json-rpc/Catalog.php	(revision 5699)
+++ sandbox/webservice/api/json-rpc/Catalog.php	(revision 5707)
@@ -7,6 +7,19 @@
 	public function getUserContacts($params){
 		if($this->isLoggedIn($params)) {
-			if($params && $params['contactID'] > 0)	
-				$query_contact = 'A.id_contact='.$params['contactID'].' and';
+			$search = "";
+			if($params) {
+				
+				$search = trim($params['search']);
+				if($params['contactID'] > 0){
+					$query_contact = 'A.id_contact='.$params['contactID'].' and';
+				}
+				elseif($search != "") {
+					$search = mb_convert_encoding($search,"ISO_8859-1", "UTF8");
+				}
+				
+				if(($search || $params['contactID']) && $params['contactType'] == 2){
+					return $this->getGlobalContacts($search, $params['contactID']);					
+				}
+			}
 			
 			$query = 'select B.id_typeof_contact_connection, A.photo, A.id_contact, A.alias, A.given_names, A.family_names, A.names_ordered, A.birthdate, A.notes, C.connection_value from phpgw_cc_contact A, '.
@@ -39,4 +52,13 @@
 						'contactHasImagePicture' => ($row['photo'] != null ? 1 : 0),
 					);
+					if($search != null && 
+							stristr($contacts[$id]['contactAlias'], $search) == null &&
+							stristr($contacts[$id]['contactFirstName'], $search) == null &&
+							stristr($contacts[$id]['contactLastName'], $search) == null &&
+							stristr($contacts[$id]['contactFullName'], $search) == null &&
+							stristr($contacts[$id]['contactBirthDate'], $search) == null &&
+							stristr($contacts[$id]['contactNotes'], $search) == null){
+						unset($contacts[$id]);
+					}
 				}				
 			}
@@ -66,10 +88,54 @@
 		return $this->getResponse();
 	}	
+
+	private function getUserLdapAttrs($mail)
+	{
+		$filter="(&(phpgwAccountType=u)(mail=".$mail."))";
+		$ldap_context = $_SESSION['phpgw_info']['expressomail']['ldap_server']['dn'];
+		$justthese = array("dn", 'jpegPhoto','givenName', 'sn'); 
+		$this->getLdapCatalog()->ldapConnect(true);
+		$ds = $this->getLdapCatalog()->ds;
+		if ($ds){
+			$sr = @ldap_search($ds, $ldap_context, $filter, $justthese);	
+			if ($sr) {
+				$entry = ldap_first_entry($ds, $sr);
+				if($entry) {									
+					$givenName = @ldap_get_values_len($ds, $entry, "givenname");
+					$sn = @ldap_get_values_len($ds, $entry, "sn");
+					$contactHasImagePicture = (@ldap_get_values_len($ds, $entry, "jpegphoto") ? 1 : 0);
+					$dn = ldap_get_dn($ds, $entry);
+					return array(
+						"contactID" => $dn,
+						"contactFirstName" => $givenName[0],
+						"contactLastName" 	=> $sn[0],
+						"contactHasImagePicture" => $contactHasImagePicture 
+					);
+				}
+			}
+		}
+		return false;
+	}	
 	
-	public function getGlobalContacts($params){
+	private function getGlobalContacts($search, $uidNumber){
+		$contacts = array();
+		$params = array ("search_for" => $search);
+ 		$result = $this->getLdapCatalog()->quicksearch($params);
+
+		foreach($result as $i => $row) {
+			if(is_int($i)) {
+				$contacts[$i] = array(
+					'contactMails'	=> array($result[$i]['mail']),
+					'contactPhones'	=> array($result[$i]['phone']),
+					'contactAlias' => "",					
+					'contactFullName' 	=> ($result[$i]['cn'] != null ? mb_convert_encoding($row['cn'],"UTF8", "ISO_8859-1") : ""),
+					'contactBirthDate'	=> "",
+					'contactNotes' 		=> ""
+				);
+				// Buscar atributos faltantes. 
+				$contacts[$i] = array_merge($this->getUserLdapAttrs($result[$i]['mail']), $contacts[$i]);				
+			}
+		}
+		$this->result = array ('contacts' => $contacts);
 		
-		if($this->isLoggedIn($params)) {
-			$this->result = array ('contacts' => $contacts);
-		}
 		return $this->getResponse();
 	}
Index: sandbox/webservice/api/json-rpc/Mail.php
===================================================================
--- sandbox/webservice/api/json-rpc/Mail.php	(revision 5670)
+++ sandbox/webservice/api/json-rpc/Mail.php	(revision 5707)
@@ -4,6 +4,6 @@
 
 class Mail extends Expresso {
-	var $defaultFolders;
-	var $imap;
+	private $defaultFolders;
+	private $imap;
 	
 	private function formatMailObject($str) {
@@ -65,6 +65,5 @@
 			$_SESSION['phpgw_info']['expressomail']['user']['userid'] = $GLOBALS['phpgw_info']['user']['userid'];
 			$_SESSION['phpgw_info']['expressomail']['user']['passwd'] = $GLOBALS['phpgw_info']['user']['passwd'];			
-			include_once(PHPGW_INCLUDE_ROOT."/expressoMail1_2/inc/class.imap_functions.inc.php");
-			$this->imap = new imap_functions();
+			$this->imap = CreateObject("expressoMail1_2.imap_functions");
 			
 			if($this->defaultFolders == null) {				
Index: sandbox/webservice/api/json-rpc/Expresso.php
===================================================================
--- sandbox/webservice/api/json-rpc/Expresso.php	(revision 5681)
+++ sandbox/webservice/api/json-rpc/Expresso.php	(revision 5707)
@@ -4,5 +4,5 @@
 
 	protected $expressoVersion;
-	protected $ldap;
+	protected $ldapCatalog;
 	var $result;
 	var $error;
@@ -29,10 +29,12 @@
 	}
 	
-	protected function getLdap(){
-		if($this->ldap == null) {
-			$this->ldap = $GLOBALS['phpgw']->common->ldapConnect();
+	protected function getLdapCatalog(){
+		if(!$this->ldapCatalog) {
+			$catalog_config = CreateObject("contactcenter.bo_ldap_manager");
+			$_SESSION['phpgw_info']['expressomail']['ldap_server'] = $catalog_config ? $catalog_config->srcs[1] : null;
+			$this->ldapCatalog = CreateObject("expressoMail1_2.ldap_functions");
 		}
 	
-		return $this->ldap;
+		return $this->ldapCatalog;
 	}
 	
