Index: trunk/jabberit_messenger/templates/default/config.tpl
===================================================================
--- trunk/jabberit_messenger/templates/default/config.tpl	(revision 519)
+++ trunk/jabberit_messenger/templates/default/config.tpl	(revision 526)
@@ -60,42 +60,32 @@
    
    <tr bgcolor="{row_on}">
-   	<td>Usar o Atributo:</td>
-   	<td>
-   		<select name="newsettings[use_attribute_jabberit]">
-   			<option value="uid" {selected_use_attribute_jabberit_uid}>uid</option>
-   			<option value="mail" {selected_use_attribute_jabberit_mail}>mail</option>
-   		</select>
-   	</td>
+		<td colspan="2">&nbsp;<b>Configurando o Nome da Empresa</b></td>
    </tr>
-
+	
 	<tr bgcolor="{row_off}">
-		<td colspan="2">&nbsp;<b>Configurando o Nome da Empresa</b></td>
-	</tr>
-	
-	<tr bgcolor="{row_on}">
 		<td id="JETTI_name_company_applet_jabberit__label">Digite o Nome da sua Empresa:</td> 
 		<td><input type="text" id="JETTI_name_company_applet_jabberit" name="newsettings[name_company_applet_jabberit]" value="{value_name_company_applet_jabberit}"></td>	
 	</tr>
 
-   <tr bgcolor="{row_off}">
+   <tr bgcolor="{row_on}">
     <td colspan="2">&nbsp;<b>Configuração do Servidor Ldap</b></td>
    </tr>
 
-   <tr bgcolor="{row_on}">
+   <tr bgcolor="{row_off}">
     <td id="JETTI_server_ldap_jabberit__label">Servidor Ldap:</td>
     <td><input type="text" id="JETTI_server_ldap_jabberit" name="newsettings[server_ldap_jabberit]" value="{value_server_ldap_jabberit}"></td>
    </tr>
 
-   <tr bgcolor="{row_off}">
+   <tr bgcolor="{row_on}">
     <td id="JETTI_context_ldap_jabberit__label">Contexto:</td>
     <td><input type="text" id="JETTI_context_ldap_jabberit" name="newsettings[context_ldap_jabberit]" value="{value_context_ldap_jabberit}" size="30"></td>
    </tr>
 
-   <tr bgcolor="{row_on}">
+   <tr bgcolor="{row_off}">
     <td id="JETTI_user_ldap_jabberit__label">Usuário Ldap:</td>
     <td><input type="text" id="JETTI_user_ldap_jabberit" name="newsettings[user_ldap_jabberit]" value="{value_user_ldap_jabberit}" size="30"></td>
    </tr>
 
-   <tr bgcolor="{row_off}">
+   <tr bgcolor="{row_on}">
     <td id="JETTI_password_ldap_jabberit__label">Password:</td>
     <td><input type="password" id="JETTI_password_ldap_jabberit" name="newsettings[password_ldap_jabberit]" value="{value_password_ldap_jabberit}"></td>
Index: trunk/jabberit_messenger/setup/phpgw_pt-br.lang
===================================================================
--- trunk/jabberit_messenger/setup/phpgw_pt-br.lang	(revision 519)
+++ trunk/jabberit_messenger/setup/phpgw_pt-br.lang	(revision 526)
@@ -27,5 +27,5 @@
 Contact Add	jabberit_messenger	pt-br	Contato Adicionado
 Custom message...	jabberit_messenger	pt-br	Mensagem ...
-Delete	jabberit_messenger	pt-br	Remover
+Delete	jabberit_messenger	pt-br	Excluir
 Description	jabberit_messenger	pt-br	Descrição
 dnd	jabberit_messenger	pt-br	Não Perturbe
Index: trunk/jabberit_messenger/inc/login.php
===================================================================
--- trunk/jabberit_messenger/inc/login.php	(revision 512)
+++ trunk/jabberit_messenger/inc/login.php	(revision 526)
@@ -21,19 +21,35 @@
 		$uid = $_SESSION['phpgw_info']['jabberit_messenger']['user'];
 		
-		if(isset($_SESSION['phpgw_info']['jabberit_messenger']['use_attribute_jabberit']))
+		$organization = explode(",", $_SESSION['phpgw_info']['jabberit_messenger']['attributes_org_ldap_jabberit']);
+
+		$organization_user = $_SESSION['phpgw_info']['jabberit_messenger']['account_dn'];
+		$organization_user = substr($organization_user, strpos($organization_user,"ou=") + 3 , strlen($organization_user));
+		$organization_user = substr($organization_user, 0, strpos($organization_user, ","));
+		
+		if(is_array($organization))
 		{
-			$attribute = $_SESSION['phpgw_info']['jabberit_messenger']['use_attribute_jabberit'];
-			
-			if( trim($attribute) == 'mail')
+			foreach($organization as $attr)
 			{
-				$uid = $_SESSION['phpgw_info']['jabberit_messenger']['mail'];
-				$uid = substr($uid,0,strpos($uid,"@"));	
+				$tmp = explode(";",$attr);
+				if( strtolower(trim($tmp[0])) == strtolower(trim($organization_user)))
+				{
+					switch(strtolower(trim($tmp[1])))
+					{
+						case "mail" :
+								$uid = $_SESSION['phpgw_info']['jabberit_messenger']['mail'];
+								$uid = substr($uid,0,strpos($uid,"@"));	
+								break;
+	
+						case "description" :
+								// SERPRO
+								// parte antes do arroba;
+								// Informe aqui a parte da sessão correspondente; 
+								$uid = "description"; 										
+								break;
+					}
+				}
 			}
-			else
-			{
-				$uid = $_SESSION['phpgw_info']['jabberit_messenger']['user'];
-			}	 
 		}
-		
+
 		$template = new Template('templates/default');
 		$template->set_var("path", $path);
Index: trunk/jabberit_messenger/inc/jabberit_sessions.inc.php
===================================================================
--- trunk/jabberit_messenger/inc/jabberit_sessions.inc.php	(revision 519)
+++ trunk/jabberit_messenger/inc/jabberit_sessions.inc.php	(revision 526)
@@ -16,4 +16,8 @@
         $_SESSION['phpgw_info']['jabberit_messenger']['passwd']		= $GLOBALS['phpgw_info']['user']['passwd'];
 		$_SESSION['phpgw_info']['jabberit_messenger']['mail']		= $GLOBALS['phpgw_info']['user']['email'];
+
+		//Organization Ldap
+		$_SESSION['phpgw_info']['jabberit_messenger']['account_dn']	= $GLOBALS['phpgw_info']['user']['account_dn'];
+
 
 		//Ldap
Index: trunk/jabberit_messenger/inc/class.ldap_im.inc.php
===================================================================
--- trunk/jabberit_messenger/inc/class.ldap_im.inc.php	(revision 519)
+++ trunk/jabberit_messenger/inc/class.ldap_im.inc.php	(revision 526)
@@ -61,4 +61,6 @@
 			$filter = "(&(phpgwaccounttype=u)(|".$uidnumber.")(".$search ."))";
 			$justthese = array("uid","uidNumber","cn","mail","phpgwAccountVisible","dn","jpegPhoto");
+			// SERPRO
+			//$justthese = array("uid","uidNumber","cn","mail","description","phpgwAccountVisible","dn","jpegPhoto");			
 			$search = ldap_search($this->ldap,$this->ldap_context,$filter,$justthese, 0, $this->max_result + 1);
 			$entry1 = ldap_get_entries($this->ldap,$search);
@@ -83,4 +85,6 @@
 						$result['uid'] = @ldap_get_values($this->ldap, $entry, 'uid');
 						$result['cn'] = @ldap_get_values($this->ldap, $entry, 'cn');
+						// SERPRO
+						//$result['description'] = @ldap_get_values($this->ldap, $entry, 'description');
 
 						foreach ( $result as $key => $value )
@@ -99,8 +103,37 @@
 							$_SESSION['phpgw_info']['jabberit_messenger']['photo'][trim($result_user[$i]['uid'])] = $photo[0];
 						}
+						
+						$organization = explode(",", $_SESSION['phpgw_info']['jabberit_messenger']['attributes_org_ldap_jabberit']);
+
+						if(is_array($organization))
+						{
+							foreach($organization as $attr)
+							{
+								$tmp = explode(";",$attr);
+								if( strtolower(trim($tmp[0])) == strtolower(trim($result_user[$i]['dn'])) )
+								{
+									switch(strtolower(trim($tmp[1])))
+									{
+										case "mail" :
+												$uid = $result_user[$i]['mail'];
+												$uid = substr($uid,0,strpos($uid,"@"));	
+												$result_user[$i]['uid'] = $uid;
+												break;
+	
+										case "description" :
+												// SERPRO
+												// parte antes do arroba; 
+												$result_user[$i]['uid'] = $result_user[$i]['description']; 										
+												break;
+									}
+								}
+							}
+						}
+						
 						$i++;
 					}				
 					$entry = ldap_next_entry($this->ldap,$entry);	
 				}
+				
 				return $result_user;
 			}
Index: trunk/jabberit_messenger/inc/class.uiconforganization.inc.php
===================================================================
--- trunk/jabberit_messenger/inc/class.uiconforganization.inc.php	(revision 519)
+++ trunk/jabberit_messenger/inc/class.uiconforganization.inc.php	(revision 526)
@@ -60,5 +60,5 @@
 		echo parse_navbar();
 
-		$options_attributes = array('uid','mail');
+		$options_attributes = array('uid','mail','description');
 		$attributes .= "<option value='-1'>-- ".lang('Choice attribute')." --</option>";
 		foreach($options_attributes as $tmp )
Index: trunk/jabberit_messenger/inc/class.ujabber.inc.php
===================================================================
--- trunk/jabberit_messenger/inc/class.ujabber.inc.php	(revision 459)
+++ trunk/jabberit_messenger/inc/class.ujabber.inc.php	(revision 526)
@@ -22,5 +22,39 @@
 		
 		$this->jabber = new Jabber();
-		$this->jabber->username	 = $_SESSION['phpgw_info']['jabberit_messenger']['user'];
+		
+		$organization = explode(",", $_SESSION['phpgw_info']['jabberit_messenger']['attributes_org_ldap_jabberit']);
+		$organization_user = $_SESSION['phpgw_info']['jabberit_messenger']['account_dn'];
+		$organization_user = substr($organization_user, strpos($organization_user,"ou=") + 3 , strlen($organization_user));
+		$organization_user = substr($organization_user, 0, strpos($organization_user, ","));
+
+		// Default para autenticação é o UID;
+		$uid = $_SESSION['phpgw_info']['jabberit_messenger']['user'];
+		
+		if(is_array($organization))
+		{
+			foreach($organization as $attr)
+			{
+				$tmp = explode(";",$attr);
+				if( strtolower(trim($tmp[0])) == strtolower(trim($organization_user)))
+				{
+					switch(strtolower(trim($tmp[1])))
+					{
+						case "mail" :
+								$uid = $_SESSION['phpgw_info']['jabberit_messenger']['mail'];
+								$uid = substr($uid,0,strpos($uid,"@"));	
+								break;
+	
+						case "description" :
+								// SERPRO
+								// parte antes do arroba;
+								// Informe aqui a parte da sessão correspondente; 
+								$uid = "description"; 										
+								break;
+					}
+				}
+			}
+		}
+		
+		$this->jabber->username	 = $uid;
 		$this->jabber->password	 = $_SESSION['phpgw_info']['jabberit_messenger']['passwd'];
 		$this->jabber->server	 = $_SESSION['phpgw_info']['jabberit_messenger']['name_jabberit'];
@@ -57,5 +91,5 @@
 		$name	= $pNewUser['name'];
 		$group	= $pNewUser['group'];
-		
+
 		if($this->jabber->RosterAddUser($jid,$id,$name,$group))
 		{
@@ -64,12 +98,16 @@
 			
 			if($this->jabber->Subscribe($jid))
+			{
+				$this->disconnect();
 				return true;
+			}
 		}
 		else
 		{
+			$this->disconnect();
 			return false;
 		}
 
-		$this->disconnect();
+		
 	}
 	
Index: trunk/jabberit_messenger/js/ldap.js
===================================================================
--- trunk/jabberit_messenger/js/ldap.js	(revision 519)
+++ trunk/jabberit_messenger/js/ldap.js	(revision 526)
@@ -161,5 +161,5 @@
 						document.getElementById('im_jid').value = m.substr(0, m.indexOf(';'));
 						document.getElementById('im_uid').value = m.substr((m.indexOf(';')+1));
-
+						
 						var _name = document.getElementById('im_name');
 
