Index: sandbox/expressoMail1_2/MailArchiver/2.2/reports/inc/class.uireports_logon.inc.php
===================================================================
--- sandbox/expressoMail1_2/MailArchiver/2.2/reports/inc/class.uireports_logon.inc.php	(revision 4644)
+++ sandbox/expressoMail1_2/MailArchiver/2.2/reports/inc/class.uireports_logon.inc.php	(revision 5035)
@@ -473,15 +473,12 @@
 			// ************ PAGINAÇÃO *******************************
 
-			// verifica se exixte usuarios no LDAP
-			$account_info = $this->functions->get_list_user_sector_logon($setordn,$contexts,0,$numacesso);
-
-			if (!count($account_info))
-			{
-				$p->set_var('message',lang('No user found'));
-				$p->parse('rows','row_empty',True);
-			}
-			else if (count($account_info))
-			{ 
-				if ($vnumacesso==0){
+
+			if ($vnumacesso==0){
+				$numreg = $this->functions->get_num_users_sector($setordn,$contexts);
+				if ($numreg==0){
+					$p->set_var('message',lang('No user found'));
+					$p->parse('rows','row_empty',True);
+				}
+				else {
 					//url do paginador 
 					$url = $GLOBALS['phpgw_info']['server']['webserver_url'].'/index.php?menuaction=reports.uireports_logon.report_logon_group_setor_print';
@@ -506,5 +503,4 @@
 	
 					// conta total dos registros
-					$numreg = count($account_info);
 					
 					// numero de registro por paginação
@@ -692,21 +688,26 @@
 					$p->set_var($vart);
 					// ************************* FIM PAGINAÇÃO ***********************							
-
-				}else{
+				}
+			}
+			else{
 				// ******** caso não for zero não vai paginar *****************
-					//url do paginador 
-					$url = $GLOBALS['phpgw_info']['server']['webserver_url'].'/index.php?menuaction=reports.uireports_logon.report_logon_group_setor_print';
-
-					// conta total dos registros
-					$numreg = count($account_info);
-
+				//url do paginador 
+				$url = $GLOBALS['phpgw_info']['server']['webserver_url'].'/index.php?menuaction=reports.uireports_logon.report_logon_group_setor_print';
+
+				// conta total dos registros
+
+				// ********** busca no LDAP as informação total e imprime ****************
+				$paginas =$this->functions->get_list_user_sector_logon($setordn,$contexts,0,$numacesso);
+				
+				if(count($paginas)==0) {
+					$p->set_var('message',lang('No user found'));
+					$p->parse('rows','row_empty',True);
+				}
+				else {
 					// Imprime valores de contagen de registro e pagina
-					$p->set_var('cont_user',$numreg);
+					$p->set_var('cont_user',count($paginas));
 					$p->set_var('cont_page',"1");
 					$p->set_var('page_now',"1");
-
-					// ********** busca no LDAP as informação paginada e imprime ****************
-					$paginas =$this->functions->get_list_user_sector_logon($setordn,$contexts,0,$numacesso);
-
+	
 					$tmpp = array();
 					$contap = 0;
@@ -748,5 +749,5 @@
 							}
 						}	
-
+	
 						if (count($sortp))
 						{
@@ -788,6 +789,6 @@
 						$p->parse('rows','row',True);
 					}
-					// ********************** Fim ****************************
-				}
+				}
+			// ********************** Fim ****************************
 			}
 
Index: sandbox/expressoMail1_2/MailArchiver/2.2/reports/inc/class.functions.inc.php
===================================================================
--- sandbox/expressoMail1_2/MailArchiver/2.2/reports/inc/class.functions.inc.php	(revision 4644)
+++ sandbox/expressoMail1_2/MailArchiver/2.2/reports/inc/class.functions.inc.php	(revision 5035)
@@ -1111,5 +1111,23 @@
 			return $total_count;
 		}
-
+		
+		function get_num_users_sector($query, $contexts) {
+			$dn			= $GLOBALS['phpgw_info']['server']['ldap_root_dn'];
+			$passwd		= $GLOBALS['phpgw_info']['server']['ldap_root_pw'];
+			$ldap_conn	= ldap_connect($GLOBALS['phpgw_info']['server']['ldap_host']);
+			ldap_set_option($ldap_conn, LDAP_OPT_PROTOCOL_VERSION, 3);
+			ldap_set_option($ldap_conn, LDAP_OPT_REFERRALS, 0);
+			ldap_bind($ldap_conn,$dn,$passwd);
+			
+			$filter="(phpgwAccountType=u)";
+			$justthese = array("uidnumber");
+			$count = 0;
+			foreach ($contexts as $index=>$context) {
+				$search = ldap_search($ldap_conn, $query, $filter, $justthese);
+				$count+=ldap_count_entries($ldap_conn, $search);
+			}
+			return $count;
+		}
+		
 		function get_list_user_sector_logon($query, $contexts,$sizelimit,$numacesso)
 		{
