Changeset 1504


Ignore:
Timestamp:
10/09/09 09:34:25 (15 years ago)
Author:
alexandrecorreia
Message:

Ticket #680 - Revertida as modificacoes para autenticacao do Modulo IM.

Location:
trunk/jabberit_messenger/inc
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/jabberit_messenger/inc/class.ldap_im.inc.php

    r1502 r1504  
    22  /***************************************************************************\ 
    33  *  Expresso - Expresso Messenger                                            * 
    4   *     - Alexandre Correia / Rodrigo Souza                                                                             * 
    5   *     - JETI - http://jeti-im.org/                                                                                                    * 
     4  *     - Alexandre Correia / Rodrigo Souza                                                               * 
     5  *     - JETI - http://jeti-im.org/                                                                              * 
    66  * ------------------------------------------------------------------------- * 
    77  *  This program is free software; you can redistribute it and/or modify it  * 
     
    1717class ldap_im 
    1818{ 
     19        private $attr_org; 
    1920        private $common; 
    2021        private $hostsJabber; 
     
    2930        public final function __construct() 
    3031        { 
     32                // Attributes org ldap; 
     33                $this->attr_org = explode(",", $_SESSION['phpgw_info']['jabberit_messenger']['attributes_org_ldap_jabberit']); 
     34                 
    3135                // Hosts Jabber 
    3236                $this->hostsJabber = unserialize($_SESSION['phpgw_info']['jabberit_messenger']['map_org_realm_jabberit']); 
     
    4751                 
    4852                $GLOBALS['phpgw_info']['server']['ldap_version3'] = true; 
    49  
    50                 $this->ldap = $this->common->ldapConnect( $this->ldap_host, $this->ldap_user . "," . $this->ldap_context , $this->ldap_pass, false ); 
     53                 
     54                if( $this->ldap_user && $this->ldap_pass ) 
     55                        $this->ldap = $this->common->ldapConnect( $this->ldap_host, $this->ldap_user . "," . $this->ldap_context , $this->ldap_pass, false ); 
     56                else 
     57                        $this->ldap = $this->common->ldapConnect( $this->ldap_host, $this->ldap_context , "", false ); 
    5158        } 
    5259         
    5360        private final function ldapRoot() 
    5461        { 
    55                 $this->ldap_host        = (isset($_SESSION['phpgw_info']['jabberit_messenger']['server_ldap_jabberit'])) ? $_SESSION['phpgw_info']['jabberit_messenger']['server_ldap_jabberit'] : $GLOBALS['phpgw_info']['server']['ldap_host']; 
    56                 $this->ldap_context     = (isset($_SESSION['phpgw_info']['jabberit_messenger']['context_ldap_jabberit'])) ? $_SESSION['phpgw_info']['jabberit_messenger']['context_ldap_jabberit'] : $GLOBALS['phpgw_info']['server']['ldap_context']; 
    57                 $this->ldap_user        = (isset($_SESSION['phpgw_info']['jabberit_messenger']['user_ldap_jabberit'])) ? $_SESSION['phpgw_info']['jabberit_messenger']['user_ldap_jabberit'] : $GLOBALS['phpgw_info']['server']['ldap_root_dn']; 
    58                 $this->ldap_pass        = (isset($_SESSION['phpgw_info']['jabberit_messenger']['password_ldap_jabberit'])) ? $_SESSION['phpgw_info']['jabberit_messenger']['password_ldap_jabberit'] : $GLOBALS['phpgw_info']['server']['ldap_root_pw']; 
     62                $this->ldap_host        = $_SESSION['phpgw_info']['jabberit_messenger']['server_ldap_jabberit']; 
     63                $this->ldap_context     = $_SESSION['phpgw_info']['jabberit_messenger']['context_ldap_jabberit']; 
     64                $this->ldap_user        = $_SESSION['phpgw_info']['jabberit_messenger']['user_ldap_jabberit']; 
     65                $this->ldap_pass        = $_SESSION['phpgw_info']['jabberit_messenger']['password_ldap_jabberit']; 
    5966 
    6067                $this->ldapConn(); 
     
    142149                if( $this->ldap ) 
    143150                { 
    144                         $filter="ou=*";          
    145                         $justthese = array("ou"); 
    146                         $search = ldap_search($this->ldap,$this->ldap_context,$filter,$justthese);                       
    147                         $entry = ldap_get_entries($this->ldap, $search); 
    148                 } 
    149  
    150                 foreach($entry as $tmp) 
    151                         if($tmp['ou'][0] != "") 
    152                                 $result_org[] = $tmp['ou'][0];   
    153  
    154                 return $result_org; 
    155         } 
    156  
     151                        $filter = "(ou=*)"; 
     152                        $justthese = array("dn"); 
     153                        $search = ldap_search($this->ldap, $this->ldap_context, $filter, $justthese); 
     154                        $info = ldap_get_entries($this->ldap, $search); 
     155                 
     156                        for ($i=0; $i<$info["count"]; $i++) 
     157                                $a_sectors[] = $info[$i]['dn'];  
     158                } 
     159 
     160                // Retiro o count do array info e inverto o array para ordenação. 
     161                foreach ($a_sectors as $context) 
     162                { 
     163                        $array_dn = ldap_explode_dn ( $context, 1 ); 
     164                        $array_dn_reverse  = array_reverse ( $array_dn, true ); 
     165                        array_pop ( $array_dn_reverse ); 
     166                        $inverted_dn[$context] = implode ( "#", $array_dn_reverse ); 
     167                } 
     168                 
     169                // Ordenação 
     170                natcasesort($inverted_dn); 
     171 
     172                foreach ( $inverted_dn as $dn=>$invert_ufn ) 
     173                { 
     174            $display = ''; 
     175 
     176            $array_dn_reverse = explode ( "#", $invert_ufn ); 
     177            $array_dn  = array_reverse ( $array_dn_reverse, true ); 
     178 
     179            $level = count( $array_dn ) - (int)(count(explode(",", $this->ldap_context)) + 1); 
     180 
     181            if ($level == 0) 
     182                    $display .= '+'; 
     183            else  
     184            { 
     185                                for( $i = 0; $i < $level; $i++) 
     186                                        $display .= '---'; 
     187            } 
     188 
     189            reset ( $array_dn ); 
     190            $display .= ' ' . (current ( $array_dn ) ); 
     191                         
     192                        $dn = trim(strtolower($dn)); 
     193                        $options[$dn] = $display; 
     194        } 
     195 
     196            return $options; 
     197 
     198        } 
    157199 
    158200        public final function getUsersLdapCatalog( $search ) 
     
    166208                { 
    167209                        $this->ldap_host        = $confHosts[$i]['serverLdap']; 
    168                         $this->ldap_context     = $confHosts[$i]['contextLdap']; 
     210                        $this->ldap_context = $confHosts[$i]['contextLdap']; 
    169211                        $this->ldap_user        = $confHosts[$i]['user']; 
    170212                        $this->ldap_org         = $confHosts[$i]['org']; 
     
    176218                        { 
    177219                                $filter = "(&(phpgwaccounttype=u)(".$search ."))"; 
    178  
    179                                 // Verificando atributo que a organização utiliza para autenticar no servidor jabber 
    180                                 switch ($_SESSION['phpgw_info']['jabberit_messenger']['user_org_att']) 
    181                                 { 
    182                                         case 'description': 
    183                         $justthese = array("uid","uidNumber","cn","description", "mail","phpgwAccountVisible","dn","jpegPhoto"); 
    184                                                 break; 
    185                                         case 'uid': 
    186                                                 $justthese = array("uid","uidNumber","cn","mail","phpgwAccountVisible","dn","jpegPhoto");        
    187                                                 break; 
    188                                         case 'mail': 
    189                                                 $justthese = array("uid","uidNumber","cn","mail","phpgwAccountVisible","dn","jpegPhoto");        
    190                                                 break; 
    191                                 } 
    192  
     220                                $justthese = array("uid","uidNumber","cn","mail","phpgwAccountVisible","dn","jpegPhoto");                                                                
    193221                                $searchRoot = ( $this->ldap_org != "*" ) ? "ou=".$this->ldap_org.",".$this->ldap_context : $this->ldap_context; 
    194222                                 
     
    220248                        $searchRoot = ( $ous ) ? $ous.",".$this->ldap_context : $this->ldap_context ; 
    221249                        $filter = "(&(phpgwaccounttype=u)(|".$uidnumber.")(".$search ."))"; 
    222  
    223                         // Verificando atributo que a organização utiliza para autenticar no servidor jabber 
    224                         switch ($_SESSION['phpgw_info']['jabberit_messenger']['user_org_att']) 
    225                         { 
    226                                 case 'description': 
    227                                         $justthese = array("uid","uidNumber","cn","description", "mail","phpgwAccountVisible","dn","jpegPhoto"); 
    228                                         break; 
    229                                 case 'uid': 
    230                                         $justthese = array("uid","uidNumber","cn","mail","phpgwAccountVisible","dn","jpegPhoto"); 
    231                                         break; 
    232                                 case 'mail': 
    233                                         $justthese = array("uid","uidNumber","cn","mail","phpgwAccountVisible","dn","jpegPhoto"); 
    234                                         break; 
    235                         } 
    236  
     250                        $justthese = array("uid","uidNumber","cn","mail","phpgwAccountVisible","dn","jpegPhoto");                                                                
    237251                        $search = ldap_search($this->ldap, $searchRoot, $filter, $justthese, 0, $this->max_result + 1); 
    238252                        $entry = ldap_get_entries( $this->ldap, $search ); 
     
    255269                        { 
    256270                                $result[$j]['uidnumber'] = $entry[$i]['uidnumber'][0];                   
    257                                 $result[$j]['mail']      = $entry[$i]['mail'][0]; 
    258                                 $result[$j]['uid']       = $entry[$i]['uid'][0]; 
    259  
    260                                 // Verificando atributo que a organização utiliza para autenticar no servidor jabber 
    261                                 switch ($_SESSION['phpgw_info']['jabberit_messenger']['user_org_att']) 
    262                                 { 
    263                                         case 'description': 
    264                                                 $result[$j]['jid'] = $entry[$i]['description'][0]; 
    265                                                 break; 
    266                                         case 'uid': 
    267                                                 $result[$j]['jid'] = $entry[$i]['uid'][0]; 
    268                                                 break; 
    269                                         case 'mail': 
    270                                                 $result[$j]['jid'] = $entry[$i]['uid'][0]; 
    271                                                 break; 
    272                                 } 
    273  
     271                                $result[$j]['mail']     =  $entry[$i]['mail'][0]; 
     272                                $result[$j]['uid']      =  $entry[$i]['uid'][0]; 
     273                                $result[$j]['jid']      = $entry[$i]['uid'][0]; 
    274274                                $ou = explode("dc=", $entry[$i]['dn']); 
    275275                                $ou = explode("ou=",$ou[0]); 
     
    283283                                        $firstEntry = ldap_first_entry($pConn, $photoLdap); 
    284284                                        $photo = ldap_get_values_len($pConn, $firstEntry, "jpegPhoto"); 
    285  
    286                                         // Verificando atributo que a organização utiliza para autenticar no servidor jabber 
    287                                         switch ($_SESSION['phpgw_info']['jabberit_messenger']['user_org_att']) 
    288                                         { 
    289                                                 case 'description': 
    290                                                         $_SESSION['phpgw_info']['jabberit_messenger']['photo'][trim($result[$j]['ou'])][trim($result[$j]['jid'])] = $photo[0]; 
    291                                                         break; 
    292                                                 case 'uid': 
    293                                                         $_SESSION['phpgw_info']['jabberit_messenger']['photo'][trim($result[$j]['ou'])][trim($result[$j]['uid'])] = $photo[0]; 
    294                                                         break; 
    295                                                 case 'mail': 
    296                                                         $_SESSION['phpgw_info']['jabberit_messenger']['photo'][trim($result[$j]['ou'])][trim($result[$j]['uid'])] = $photo[0]; 
    297                                                         break; 
    298                                         } 
     285                                        $_SESSION['phpgw_info']['jabberit_messenger']['photo'][trim($result[$j]['ou'])][trim($result[$j]['uid'])] = $photo[0]; 
    299286                                } 
    300287                                else 
     
    303290                                $result[$j++]['cn']     = $entry[$i]['cn'][0]; 
    304291                        } 
    305                                          
    306                         // Verificando atributo que a organização utiliza para autenticar no servidor jabber 
    307                         switch ($_SESSION['phpgw_info']['jabberit_messenger']['user_org_att']) 
     292                 
     293                        $organization = $this->attr_org; 
     294         
     295                        if(is_array($organization)) 
    308296                        { 
    309                                 case 'description': 
    310                                         $result[$i]['uid'] = $result[$i]['description']; 
    311                                         break; 
    312                                 case 'uid': 
    313                                         $uid = $result[$i]['mail']; 
    314                                         $uid = substr($uid,0,strpos($uid,"@"));  
    315                                         $result[$i]['uid'] = $uid; 
    316                                         break; 
    317                                 case 'mail': 
    318                                         $uid = $result[$i]['mail']; 
    319                                         $uid = substr($uid,0,strpos($uid,"@"));  
    320                                         $result[$i]['uid'] = $uid; 
    321                                         break;   
     297                                foreach($organization as $attr) 
     298                                { 
     299                                        $tmp = explode(";",$attr); 
     300                                        if( strtolower(trim($tmp[0])) == strtolower(trim($result[$i]['dn'])) ) 
     301                                        { 
     302                                                switch(strtolower(trim($tmp[1]))) 
     303                                                { 
     304                                                        case "mail" : 
     305                                                                        $uid = $result[$i]['mail']; 
     306                                                                        $uid = substr($uid,0,strpos($uid,"@"));  
     307                                                                        $result[$i]['uid'] = $uid; 
     308                                                                        break; 
     309         
     310                                                        case "description" : 
     311                                                                        // SERPRO 
     312                                                                        // parte antes do arroba;  
     313                                                                        $result[$i]['uid'] = $result[$i]['description'];                                                                                 
     314                                                                        break; 
     315                                                } 
     316                                        } 
     317                                } 
    322318                        } 
    323319                } 
  • trunk/jabberit_messenger/inc/jabberit_sessions.inc.php

    r1502 r1504  
    1111  \***************************************************************************/ 
    1212 
     13                //User 
     14                $_SESSION['phpgw_info']['jabberit_messenger']['user_jabber']    = $GLOBALS['phpgw_info']['user']['account_lid']; 
     15                $_SESSION['phpgw_info']['jabberit_messenger']['user_id']                = $GLOBALS['phpgw_info']['user']['account_id'];          
     16        $_SESSION['phpgw_info']['jabberit_messenger']['passwd']                 = $GLOBALS['phpgw_info']['user']['passwd']; 
     17                $_SESSION['phpgw_info']['jabberit_messenger']['mail']                   = $GLOBALS['phpgw_info']['user']['email']; 
     18                $_SESSION['phpgw_info']['jabberit_messenger']['fullname']               = $GLOBALS['phpgw_info']['user']['fullname']; 
     19                $_SESSION['phpgw_info']['jabberit_messenger']['account_dn']             = $GLOBALS['phpgw_info']['user']['account_dn']; 
    1320 
    14         // Identifica que atributo a organização utiliza para autenticar no servidor jabber 
    15         $ou = explode(",",$GLOBALS['phpgw_info']['user']['account_dn']); 
    16         $ou = explode("=",$ou[3]); 
    17         $ou = $ou[1]; 
     21                // User Lang  
     22                $_SESSION['phpgw_info']['jabberit_messenger']['applet_lang']    = $GLOBALS['phpgw_info']['user']['preferences']['common']['lang'];  
     23                 
     24                //Members Group 
     25                $_SESSION['phpgw_info']['jabberit_messenger']['membership']             = $GLOBALS['phpgw']->accounts->membership(); 
    1826 
    19         $org_array = explode(",",$GLOBALS['phpgw_info']['server']['attributes_org_ldap_jabberit']); 
     27                //Groups Locked 
     28                $_SESSION['phpgw_info']['jabberit_messenger']['groups_locked']  = $GLOBALS['phpgw_info']['server']['groups_locked_jabberit']; 
    2029 
    21         for($i = 0; $i < sizeof($org_array); ++$i) 
    22         { 
    23             $org = explode(";",$org_array[$i]); 
    24             if ($org[0] == $ou) 
    25             { 
    26                 $org = $org[1];  
    27                 break; 
    28             } 
    29         } 
     30                //Server http or https  
     31                $_SESSION['phpgw_info']['jabberit_messenger']['use_https']              = $GLOBALS['phpgw_info']['server']['use_https']; 
    3032 
    31         $_SESSION['phpgw_info']['jabberit_messenger']['user_org_att'] = $org; 
    32          
    33         // Seta a variável user_jabber de acordo com o atributo adotado pela organização 
    34         switch ($org)  
    35         { 
    36                 case 'uid': 
    37                         $_SESSION['phpgw_info']['jabberit_messenger']['user_jabber'] = $GLOBALS['phpgw_info']['user']['account_lid']; 
    38                         break; 
    39                 case 'mail': 
    40                         $_SESSION['phpgw_info']['jabberit_messenger']['user_jabber'] = $GLOBALS['phpgw_info']['user']['mail']; 
    41                         break; 
    42                 case 'description': 
    43                 $description = explode("@", $GLOBALS['phpgw_info']['user']['email']); 
    44                         $_SESSION['phpgw_info']['jabberit_messenger']['user_jabber'] = $description[0]; 
    45                         break; 
    46         } 
    47          
    48         $_SESSION['phpgw_info']['jabberit_messenger']['user_id']                = $GLOBALS['phpgw_info']['user']['account_id'];          
    49    $_SESSION['phpgw_info']['jabberit_messenger']['passwd']              = $GLOBALS['phpgw_info']['user']['passwd']; 
    50         $_SESSION['phpgw_info']['jabberit_messenger']['mail']                   = $GLOBALS['phpgw_info']['user']['email']; 
    51         $_SESSION['phpgw_info']['jabberit_messenger']['fullname']       = $GLOBALS['phpgw_info']['user']['fullname']; 
    52         $_SESSION['phpgw_info']['jabberit_messenger']['account_dn']     = $GLOBALS['phpgw_info']['user']['account_dn']; 
     33                //Organization Ldap 
     34                $_SESSION['phpgw_info']['jabberit_messenger']['account_dn']             = $GLOBALS['phpgw_info']['user']['account_dn']; 
    5335 
    54         // User Lang  
    55         $_SESSION['phpgw_info']['jabberit_messenger']['applet_lang'] = $GLOBALS['phpgw_info']['user']['preferences']['common']['lang'];  
    56          
    57         //Members Group 
    58         $_SESSION['phpgw_info']['jabberit_messenger']['membership']     = $GLOBALS['phpgw']->accounts->membership(); 
     36                //Ldap 
     37                $_SESSION['phpgw_info']['jabberit_messenger']['server_ldap_jabberit']   = $GLOBALS['phpgw_info']['server']['server_ldap_jabberit']; 
     38        $_SESSION['phpgw_info']['jabberit_messenger']['context_ldap_jabberit']  = $GLOBALS['phpgw_info']['server']['context_ldap_jabberit']; 
     39        $_SESSION['phpgw_info']['jabberit_messenger']['user_ldap_jabberit']     = $GLOBALS['phpgw_info']['server']['user_ldap_jabberit']; 
     40        $_SESSION['phpgw_info']['jabberit_messenger']['password_ldap_jabberit'] = $GLOBALS['phpgw_info']['server']['password_ldap_jabberit']; 
     41         
     42        //DB 
     43        $_SESSION['phpgw_info']['jabberit_messenger']['server']['db_name']       = $GLOBALS['phpgw_info']['server']['db_name']; 
     44        $_SESSION['phpgw_info']['jabberit_messenger']['server']['db_host']       = $GLOBALS['phpgw_info']['server']['db_host']; 
     45        $_SESSION['phpgw_info']['jabberit_messenger']['server']['db_port']       = $GLOBALS['phpgw_info']['server']['db_port']; 
     46        $_SESSION['phpgw_info']['jabberit_messenger']['server']['db_user']       = $GLOBALS['phpgw_info']['server']['db_user']; 
     47        $_SESSION['phpgw_info']['jabberit_messenger']['server']['db_pass']       = $GLOBALS['phpgw_info']['server']['db_pass']; 
     48        $_SESSION['phpgw_info']['jabberit_messenger']['server']['db_type']       = $GLOBALS['phpgw_info']['server']['db_type']; 
    5949 
    60         //Groups Locked 
    61         $_SESSION['phpgw_info']['jabberit_messenger']['groups_locked'] = $GLOBALS['phpgw_info']['server']['groups_locked_jabberit']; 
    62  
    63         //Server http or https  
    64         $_SESSION['phpgw_info']['jabberit_messenger']['use_https']      = $GLOBALS['phpgw_info']['server']['use_https']; 
    65  
    66         //Organization Ldap 
    67         $_SESSION['phpgw_info']['jabberit_messenger']['account_dn']     = $GLOBALS['phpgw_info']['user']['account_dn']; 
    68  
    69         //Ldap 
    70         $_SESSION['phpgw_info']['jabberit_messenger']['server_ldap_jabberit']   = $GLOBALS['phpgw_info']['server']['server_ldap_jabberit']; 
    71    $_SESSION['phpgw_info']['jabberit_messenger']['context_ldap_jabberit']  = $GLOBALS['phpgw_info']['server']['context_ldap_jabberit']; 
    72    $_SESSION['phpgw_info']['jabberit_messenger']['user_ldap_jabberit']     = $GLOBALS['phpgw_info']['server']['user_ldap_jabberit']; 
    73    $_SESSION['phpgw_info']['jabberit_messenger']['password_ldap_jabberit'] = $GLOBALS['phpgw_info']['server']['password_ldap_jabberit']; 
    74          
    75    //DB 
    76    $_SESSION['phpgw_info']['jabberit_messenger']['server']['db_name']    = $GLOBALS['phpgw_info']['server']['db_name']; 
    77    $_SESSION['phpgw_info']['jabberit_messenger']['server']['db_host']    = $GLOBALS['phpgw_info']['server']['db_host']; 
    78    $_SESSION['phpgw_info']['jabberit_messenger']['server']['db_port']    = $GLOBALS['phpgw_info']['server']['db_port']; 
    79    $_SESSION['phpgw_info']['jabberit_messenger']['server']['db_user']    = $GLOBALS['phpgw_info']['server']['db_user']; 
    80    $_SESSION['phpgw_info']['jabberit_messenger']['server']['db_pass']    = $GLOBALS['phpgw_info']['server']['db_pass']; 
    81    $_SESSION['phpgw_info']['jabberit_messenger']['server']['db_type']    = $GLOBALS['phpgw_info']['server']['db_type']; 
    82  
    83         //Jabberd 
    84    $_SESSION['phpgw_info']['jabberit_messenger']['name_jabberit']                                               = $GLOBALS['phpgw_info']['server']['name_jabberit']; 
    85    $_SESSION['phpgw_info']['jabberit_messenger']['port_jabberit']                                               = $GLOBALS['phpgw_info']['server']['port_jabberit']; 
    86    $_SESSION['phpgw_info']['jabberit_messenger']['resource_jabberit']                           = $GLOBALS['phpgw_info']['server']['resource_jabberit']; 
    87    $_SESSION['phpgw_info']['jabberit_messenger']['group_chat_jabberit']                         = $GLOBALS['phpgw_info']['server']['group_chat_server_jabberit']; 
    88         $_SESSION['phpgw_info']['jabberit_messenger']['use_ssl_jabberit']                                       = $GLOBALS['phpgw_info']['server']['use_ssl_jabberit']; 
    89         $_SESSION['phpgw_info']['jabberit_messenger']['use_proxy_java']                                 = $GLOBALS['phpgw_info']['server']['use_proxy_java']; 
    90         $_SESSION['phpgw_info']['jabberit_messenger']['name_company']                                           = $GLOBALS['phpgw_info']['server']['name_company_applet_jabberit']; 
    91         $_SESSION['phpgw_info']['jabberit_messenger']['use_attribute_jabberit']                 = $GLOBALS['phpgw_info']['server']['use_attribute_jabberit']; 
    92         $_SESSION['phpgw_info']['jabberit_messenger']['attributes_org_ldap_jabberit']   = $GLOBALS['phpgw_info']['server']['attributes_org_ldap_jabberit']; 
    93         $_SESSION['phpgw_info']['jabberit_messenger']['map_org_realm_jabberit']                 = $GLOBALS['phpgw_info']['server']['map_org_realm_jabberit']; 
     50                //Jabberd 
     51        $_SESSION['phpgw_info']['jabberit_messenger']['name_jabberit']                                  = $GLOBALS['phpgw_info']['server']['name_jabberit']; 
     52        $_SESSION['phpgw_info']['jabberit_messenger']['ip_server_jabberit']                             = $GLOBALS['phpgw_info']['server']['ip_server_jabberit']; 
     53        $_SESSION['phpgw_info']['jabberit_messenger']['port_1_jabberit']                                = $GLOBALS['phpgw_info']['server']['port_1_jabberit']; 
     54        $_SESSION['phpgw_info']['jabberit_messenger']['port_2_jabberit']                                = $GLOBALS['phpgw_info']['server']['port_2_jabberit'];         
     55        $_SESSION['phpgw_info']['jabberit_messenger']['resource_jabberit']                              = $GLOBALS['phpgw_info']['server']['resource_jabberit']; 
     56        $_SESSION['phpgw_info']['jabberit_messenger']['group_chat_jabberit']                    = $GLOBALS['phpgw_info']['server']['group_chat_server_jabberit']; 
     57                $_SESSION['phpgw_info']['jabberit_messenger']['name_company']                                   = $GLOBALS['phpgw_info']['server']['name_company_applet_jabberit']; 
     58                $_SESSION['phpgw_info']['jabberit_messenger']['use_attribute_jabberit']                 = $GLOBALS['phpgw_info']['server']['use_attribute_jabberit']; 
     59                $_SESSION['phpgw_info']['jabberit_messenger']['attributes_org_ldap_jabberit']   = $GLOBALS['phpgw_info']['server']['attributes_org_ldap_jabberit']; 
     60                $_SESSION['phpgw_info']['jabberit_messenger']['map_org_realm_jabberit']                 = $GLOBALS['phpgw_info']['server']['map_org_realm_jabberit']; 
    9461 
    9562?> 
  • trunk/jabberit_messenger/inc/login.php

    r1502 r1504  
    22  /***************************************************************************\ 
    33  *  Expresso - Expresso Messenger                                            * 
    4   *     - Alexandre Correia / Rodrigo Souza                                                                                     * 
    5   *     - JETI - http://jeti-im.org/                                                                                                                    * 
     4  *     - Alexandre Correia / Rodrigo Souza                                                               * 
     5  *     - JETI - http://jeti-im.org/                                                                              * 
    66  * ------------------------------------------------------------------------- * 
    77  *  This program is free software; you can redistribute it and/or modify it  * 
     
    1616 
    1717        if(isset($_SESSION['phpgw_info']['jabberit_messenger']['name_jabberit'])) 
    18         { 
     18    { 
    1919                // Path Server 
    2020                $path = $_SESSION['phpgw_info']['jabberit_messenger']['webserver_url']; 
     
    2424                 ******  Type Protocol http / https ********************************************************** 
    2525                 *      Esta variável é carregada no header.inc.php, onde é possível definir 
    26                  *      se será com http ou https. Verifique em seu arquivo header.inc.php como está configurada 
     26                 *      se será com http ou https. Verifique em seu arquivo header.inc.php como está configurada 
    2727                 *      a variável $GLOBALS['phpgw_info']['server']['use_https'].  
    2828                 *      Abaixo segue esquema : 
    2929                 *      Expresso 0 = Sem https 
    3030                 *      Expresso 1 = Com https apenas no login 
    31                  *      Expresso 2 = Completo 
     31                 *      Expresso 2 = Completo 
    3232                 ********************************************************************************************* 
    3333                 **/ 
    3434 
    35                 // ESSA VARIAVEL PRECISA REFLETIR A CONFIGURACAO DO PRIMEIRO PROXY 
    36       $PROTOCOL = trim("http"); 
     35                $PROTOCOL = trim("http"); 
     36                if( $_SESSION['phpgw_info']['jabberit_messenger']['use_https'] === 2 ) 
     37                        $PROTOCOL = trim("https"); 
    3738 
    38       $pattern = '/https:\/\//'; 
    39       if (preg_match($pattern,$_SERVER[HTTP_REFERER])) 
    40         $PROTOCOL = trim("https"); 
     39                // Uid user 
     40                $uid = $_SESSION['phpgw_info']['jabberit_messenger']['user_jabber']; 
     41                 
     42                $organization = explode(",", $_SESSION['phpgw_info']['jabberit_messenger']['attributes_org_ldap_jabberit']); 
    4143 
    42                 // UID 
    43                 // Verificando atributo que a organização utiliza para autenticar no servidor jabber 
    44       switch ($_SESSION['phpgw_info']['jabberit_messenger']['user_org_att']) 
    45                 { 
    46         case 'description': 
    47                                 $uid = $_SESSION['phpgw_info']['jabberit_messenger']['user_jabber']; 
    48             break; 
    49          case 'uid': 
    50             $uid = $_SESSION['phpgw_info']['jabberit_messenger']['user_id']; 
    51                                 $uid = substr($uid,0,strpos($uid,"@")); 
    52             break; 
    53                 case 'mail': 
    54                 $uid = $_SESSION['phpgw_info']['jabberit_messenger']['user_id']; 
    55                                 $uid = substr($uid,0,strpos($uid,"@")); 
    56             break; 
    57         } 
    58  
     44                $organization_user = $_SESSION['phpgw_info']['jabberit_messenger']['account_dn']; 
     45                $organization_user = substr($organization_user, strpos($organization_user,"ou=") + 3 , strlen($organization_user)); 
     46                $organization_user = substr($organization_user, 0, strpos($organization_user, ",")); 
     47                 
    5948                // FirstName 
    6049                $CnName = explode(" ",$_SESSION['phpgw_info']['jabberit_messenger']['fullname']); 
     
    6655                $preferences = explode(":", $preferences); 
    6756                 
     57                if(is_array($organization)) 
     58                { 
     59                        foreach($organization as $attr) 
     60                        { 
     61                                $tmp = explode(";",$attr); 
     62                                if( strtolower(trim($tmp[0])) == strtolower(trim($organization_user))) 
     63                                { 
     64                                        switch(strtolower(trim($tmp[1]))) 
     65                                        { 
     66                                                case "mail" : 
     67                                                                $uid = $_SESSION['phpgw_info']['jabberit_messenger']['mail']; 
     68                                                                $uid = substr($uid,0,strpos($uid,"@"));  
     69                                                                break; 
     70         
     71                                                case "description" : 
     72                                                                // SERPRO 
     73                                                                // parte antes do arroba; 
     74                                                                // Informe aqui a parte da sessão correspondente;  
     75                                                                $uid = "description";                                                                            
     76                                                                break; 
     77                                        } 
     78                                } 
     79                        } 
     80                } 
    6881 
    6982                //Enable/Disable VoIP Service -> Voip Server Config 
     
    114127                $language = $lang[0]; 
    115128                 
     129                // Porta/(SSL)?                  
     130                $conn_SSL = "false"; 
     131                $port_jabber = "5222"; 
     132                 
     133                if( $_SESSION['phpgw_info']['jabberit_messenger']['port_1_jabberit'] === "true" ) 
     134                {        
     135                        $conn_SSL = "true"; 
     136                        $port_jabber = "5223"; 
     137                } 
     138                                 
     139                if( trim($_SESSION['phpgw_info']['jabberit_messenger']['port_2_jabberit']) ) 
     140                {                
     141                        $port_jabber = $_SESSION['phpgw_info']['jabberit_messenger']['port_2_jabberit']; 
     142                } 
     143                 
    116144                // Load Template; 
    117145                $template = new Template('templates/default'); 
     
    123151                $template->set_var("value_country", $country); 
    124152                $template->set_var("value_expresso", $SERVER_EXPRESSO);          
    125                 $template->set_var("value_host", $_SESSION['phpgw_info']['jabberit_messenger']['name_jabberit']); 
     153                $template->set_var("value_host", $_SESSION['phpgw_info']['jabberit_messenger']['ip_server_jabberit']); 
    126154                $template->set_var("value_javaPlugins", $javaPlugins); 
    127155                $template->set_var("value_language", $language);                         
    128156                $template->set_var("value_password", $_SESSION['phpgw_info']['jabberit_messenger']['passwd']); 
    129                 $template->set_var("value_port", $_SESSION['phpgw_info']['jabberit_messenger']['port_jabberit']); 
     157                $template->set_var("value_port", $port_jabber); 
    130158                $template->set_var("value_resource", $_SESSION['phpgw_info']['jabberit_messenger']['resource_jabberit']); 
    131159                $template->set_var("value_server", $_SESSION['phpgw_info']['jabberit_messenger']['name_jabberit']); 
    132                 $template->set_var("value_ssl", $_SESSION['phpgw_info']['jabberit_messenger']['use_ssl_jabberit']); 
     160                $template->set_var("value_ssl", $conn_SSL); 
    133161                $template->set_var("value_use_https", $PROTOCOL); 
    134162                $template->set_var("value_user", $uid); 
    135                 $template->set_var("value_userproxy", $_SESSION['phpgw_info']['jabberit_messenger']['use_proxy_java']); 
    136                  
     163 
    137164                if( strpos($_SERVER['HTTP_USER_AGENT'], "MSIE") ) 
    138165                        $template->set_file(Array('jabberit_messenger' => 'jabberIM_IE.tpl')); 
  • trunk/jabberit_messenger/inc/webservice.php

    r1502 r1504  
    3131                        $handle   = unserialize(base64_decode($LDAP_INTERNAL)); 
    3232         
    33                         $this->jabberName               = $handle['jabberName']; 
    34                         $this->serverLdap               = $handle['serverLdap']; 
     33                        $this->jabberName       = $handle['jabberName']; 
     34                        $this->serverLdap       = $handle['serverLdap']; 
    3535                        $this->contextLdap      = $handle['contextLdap']; 
    3636                        $this->userLDAP         = $handle['user']; 
    37                         $this->passwd                   = $handle['password']; 
     37                        $this->passwd           = $handle['password']; 
    3838                         
    3939                        $this->refer    = true; 
     
    170170                 
    171171                if( $this->jabberName == (substr($pJid, strpos($pJid, "@") + 1 ))) 
     172                { 
    172173                        $this->ldapConnect(); 
     174 
     175                        if( $this->fileLdapInternal ) 
     176                        { 
     177                                if( $this->conn ) 
     178                                { 
     179                                        $filter = "(&(phpgwaccounttype=u)(uid=".$uid.")(!(phpgwaccountvisible=-1)))"; 
     180                                        $justthese = array("uid","cn","dn"); 
     181                                        $search = ldap_search( $this->conn, $this->contextLdap, $filter,$justthese); 
     182                                        $get_entries = ldap_get_entries( $this->conn, $search); 
     183                 
     184                                        if( $get_entries['count'] > 0 ) 
     185                                        {                                        
     186                                                $cn = $get_entries[0]['cn'][0]; 
     187                                                $ou = explode("dc=", $get_entries[0]['dn']); 
     188                                                $ou = explode("ou=",$ou[0]); 
     189                                                $ou = array_pop($ou); 
     190                                                $dn = strtoupper(substr($ou,0,strlen($ou)-1)); 
     191                                                $return = utf8_encode("Nome : " . $cn . ";Organização : " . $dn); 
     192                                        } 
     193                                } 
     194                        } 
     195                } 
    173196                else 
     197                { 
    174198                        $this->ldapConnectExternal(substr($pJid, strpos($pJid, "@") + 1 )); 
    175  
    176                 if( $this->conn ) 
    177                 { 
    178                         // Verificando atributo que a organização utiliza para autenticar no servidor jabber 
    179                         switch ($_SESSION['phpgw_info']['jabberit_messenger']['user_org_att']) 
    180                         { 
    181                                 case 'description': 
    182                                         $filter = "(&(phpgwaccounttype=u)(description=".$uid.")(!(phpgwaccountvisible=-1)))"; 
    183                                         break; 
    184                                 case 'uid': 
     199                         
     200                        if( $this->fileLdapExternal ) 
     201                        { 
     202                                if( $this->conn ) 
     203                                { 
    185204                                        $filter = "(&(phpgwaccounttype=u)(uid=".$uid.")(!(phpgwaccountvisible=-1)))"; 
    186                                         break; 
    187                                 case 'mail': 
    188                                         $filter = "(&(phpgwaccounttype=u)(uid=".$uid.")(!(phpgwaccountvisible=-1)))"; 
    189                                         break; 
    190                         } 
    191  
    192                         $justthese = array("uid","cn","dn"); 
    193                         $search = ldap_search( $this->conn, $this->contextLdap, $filter, $justthese); 
    194                         $get_entries = ldap_get_entries( $this->conn, $search); 
     205                                        $justthese = array("uid","cn","dn"); 
     206                                        $search = ldap_search( $this->conn, $this->contextLdap, $filter, $justthese); 
     207                                        $get_entries = ldap_get_entries( $this->conn, $search); 
    195208                                         
    196                         if( $get_entries['count'] > 0 ) 
    197                         { 
    198                                 $cn = $get_entries[0]['cn'][0]; 
    199                                 $ou = explode("dc=", $get_entries[0]['dn']); 
    200                                 $ou = explode("ou=",$ou[0]); 
    201                                 $ou = array_pop($ou); 
    202                                 $dn = strtoupper(substr($ou,0,strlen($ou)-1)); 
    203                                 $return = utf8_encode("Nome : " . $cn . ";Organização : " . $dn); 
     209                                        if( $get_entries['count'] > 0 ) 
     210                                        { 
     211                                                $cn = $get_entries[0]['cn'][0]; 
     212                                                $ou = explode("dc=", $get_entries[0]['dn']); 
     213                                                $ou = explode("ou=",$ou[0]); 
     214                                                $ou = array_pop($ou); 
     215                                                $dn = strtoupper(substr($ou,0,strlen($ou)-1)); 
     216                                                $return = utf8_encode("Nome : " . $cn . ";Organização : " . $dn); 
     217                                        } 
     218                                } 
    204219                        } 
    205220                } 
     
    224239                                 
    225240                                $this->ldapConnect(); 
     241                                 
     242                                if( $this->conn ) 
     243                                { 
     244                                        $filter                 = "(&(phpgwaccounttype=u)(uid=".$uid.")(!(phpgwaccountvisible=-1)))"; 
     245                                        $justthese              = array("uid","jpegPhoto"); 
     246                                        $search                 = ldap_search($this->conn,$this->contextLdap,$filter,$justthese); 
     247                                        $get_entries    = ldap_get_entries($this->conn,$search); 
     248                                         
     249                                        if( $get_entries['count'] > 0 ) 
     250                                        { 
     251                                                $first_entry = ldap_first_entry( $this->conn, $search ); 
     252                                                $photo = @ldap_get_values_len($this->conn, $first_entry, 'jpegphoto'); 
     253                                                 
     254                                                if ( $photo ) 
     255                                                        return $photo[0]; 
     256                                                 
     257                                                return false;                                                            
     258                                        } 
     259                                } 
    226260                        } 
    227261                } 
     
    237271                        if( !$this->fileLdapExternal ) 
    238272                                return false; 
    239                 } 
    240  
    241                 if( $this->conn ) 
    242                 { 
    243                         // Verificando atributo que a organização utiliza para autenticar no servidor jabber 
    244                         switch ($_SESSION['phpgw_info']['jabberit_messenger']['user_org_att']) 
    245                         { 
    246                                 case 'description': 
    247                                         $filter = "(&(phpgwaccounttype=u)(description=".$uid.")(!(phpgwaccountvisible=-1)))"; 
    248                                         $justthese = array("description","jpegPhoto"); 
    249                                         break; 
    250                                 case 'uid': 
    251                                         $filter = "(&(phpgwaccounttype=u)(uid=".$uid.")(!(phpgwaccountvisible=-1)))"; 
    252                                         $justthese = array("uid","jpegPhoto"); 
    253                                         break; 
    254                                 case 'mail': 
    255                                         $filter = "(&(phpgwaccounttype=u)(uid=".$uid.")(!(phpgwaccountvisible=-1)))"; 
    256                                         $justthese = array("uid","jpegPhoto"); 
    257                                         break; 
    258                         } 
    259  
    260                         $search                 = ldap_search($this->conn,$this->contextLdap,$filter,$justthese); 
    261                         $get_entries    = ldap_get_entries($this->conn,$search); 
     273 
     274                        if( $this->conn ) 
     275                        { 
     276                                $filter                 = "(&(phpgwaccounttype=u)(uid=".$uid.")(!(phpgwaccountvisible=-1)))"; 
     277                                $justthese              = array("uid","jpegPhoto"); 
     278                                $search                 = ldap_search($this->conn,$this->contextLdap,$filter,$justthese); 
     279                                $get_entries    = ldap_get_entries($this->conn,$search); 
    262280                                 
    263                         if( $get_entries['count'] > 0 ) 
    264                         { 
    265                                 $first_entry = ldap_first_entry( $this->conn, $search ); 
    266                                 $photo = @ldap_get_values_len($this->conn, $first_entry, 'jpegphoto'); 
    267                                  
    268                                 if ( $photo ) 
    269                                         return $photo[0]; 
    270                                  
    271                                 return false;                                                            
     281                                if( $get_entries['count'] > 0 ) 
     282                                { 
     283                                        $first_entry = ldap_first_entry( $this->conn, $search ); 
     284                                        $photo = @ldap_get_values_len($this->conn, $first_entry, 'jpegphoto'); 
     285                                         
     286                                        if ( $photo ) 
     287                                                return $photo[0]; 
     288                                         
     289                                        return false;                                                            
     290                                } 
    272291                        } 
    273292                } 
Note: See TracChangeset for help on using the changeset viewer.