Ignore:
Timestamp:
12/28/09 15:59:20 (14 years ago)
Author:
alexandrecorreia
Message:

Ticket #860 - Corrigir quando a autenticacao do jabber nao e pelo campo uid do ldap.

File:
1 edited

Legend:

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

    r1881 r1900  
    2020class ldap_im 
    2121{ 
    22         private $attr_org; 
     22        private $attribute; 
    2323        private $common; 
    2424        private $hostsJabber; 
     
    3838                $this->ldap_pass        = $_SESSION['phpgw_info']['jabberit_messenger']['password_ldap_jabberit']; 
    3939 
    40                 // Attributes org ldap; 
    41                 $this->attr_org = explode(",", $_SESSION['phpgw_info']['jabberit_messenger']['attributes_org_ldap_jabberit']); 
    42                  
    4340                // Hosts Jabber 
    4441                $this->hostsJabber = unserialize($_SESSION['phpgw_info']['jabberit_messenger']['map_org_realm_jabberit']); 
     
    4744                $this->max_result = 30; 
    4845                 
     46                if ( file_exists('inc/attributeLdap.php') ) 
     47                { 
     48                        require_once('attributeLdap.php'); 
     49                        $this->attribute = trim($attributeTypeName); 
     50                } 
    4951        } 
    5052 
     
    333335                        { 
    334336                                $filter         = ( $uid ) ? "(&(phpgwaccounttype=u)(|".$uid.")(".$search ."))" : "(&(phpgwaccounttype=u)(".$search ."))"; 
    335                                 $justthese      = array("uid","uidNumber","cn","mail","phpgwAccountVisible","dn","jpegPhoto");                                                           
     337                                $justthese      = array( $this->attribute ,"uidNumber" ,"cn" ,"mail" ,"phpgwAccountVisible" ,"dn" ,"jpegPhoto" );                                                                
    336338                                $searchRoot     = ( $this->ldap_org != "*" ) ? "ou=".$this->ldap_org.",".$this->ldap_context : $this->ldap_context; 
    337339                                $search1        = @ldap_search($this->ldap, $searchRoot, $filter, $justthese, 0, $this->max_result + 1); 
     
    358360                        $searchRoot     = ( $ous ) ? $ous.",".$this->ldap_context : $this->ldap_context ; 
    359361                        $filter         = "(&(phpgwaccounttype=u)(|".$uidnumber.")(".$search ."))"; 
    360                         $justthese      = array("uid","uidNumber","cn","mail","phpgwAccountVisible","dn","jpegPhoto");                                                           
     362                        $justthese      = array( $this->attribute, "uidNumber", "cn", "mail", "phpgwAccountVisible", "dn", "jpegPhoto" );                                                                
    361363                        $search         = ldap_search( $this->ldap, $searchRoot, $filter, $justthese, 0, $this->max_result + 1); 
    362364                        $entry          = ldap_get_entries( $this->ldap, $search ); 
     
    369371        private final function resultArray($pArray, $pConn, $pOrg = false) 
    370372        { 
    371                 $entry = $pArray; 
    372                 $result = array(); 
    373  
    374                 $j = 0; 
    375                 for($i = 0 ; $i < $entry['count']; $i++) 
     373                $entry  = $pArray; 
     374                $result = array(); 
     375                $j              = 0; 
     376                 
     377                for( $i = 0 ; $i < $entry['count']; $i++ ) 
    376378                { 
    377379                        if ( $entry[$i]['phpgwaccountvisible'][0] != '-1' ) 
    378380                        { 
    379                                 $result[$j]['uidnumber'] = $entry[$i]['uidnumber'][0];                   
    380                                 $result[$j]['mail']     =  $entry[$i]['mail'][0]; 
    381                                 $result[$j]['uid']      =  $entry[$i]['uid'][0]; 
    382                                 $result[$j]['jid']      = $entry[$i]['uid'][0]; 
     381                                $result[$j]['uidnumber']        = $entry[$i]['uidnumber'][0];                    
     382                                $result[$j]['mail']                     = $entry[$i]['mail'][0]; 
     383                                $result[$j]['uid']                      = $entry[$i][$this->attribute][0]; 
     384                                $result[$j]['jid']                      = $entry[$i][$this->attribute][0]; 
     385                                 
    383386                                $ou = explode("dc=", $entry[$i]['dn']); 
    384387                                $ou = explode("ou=",$ou[0]); 
    385388                                $ou = array_pop($ou); 
    386389                                $result[$j]['ou']       = strtoupper(substr($ou,0,strlen($ou)-1)); 
     390                                 
    387391                                if( $pOrg === "*" ) 
    388392                                        $result[$j]['ouAll'] = "*"; 
     
    404408                 
    405409                        $organization = $this->attr_org; 
    406          
    407                         if(is_array($organization)) 
    408                         { 
    409                                 foreach($organization as $attr) 
    410                                 { 
    411                                         $tmp = explode(";",$attr); 
    412                                         if( strtolower(trim($tmp[0])) == strtolower(trim($result[$i]['dn'])) ) 
    413                                         { 
    414                                                 switch(strtolower(trim($tmp[1]))) 
    415                                                 { 
    416                                                         case "mail" : 
    417                                                                         $uid = $result[$i]['mail']; 
    418                                                                         $uid = substr($uid,0,strpos($uid,"@"));  
    419                                                                         $result[$i]['uid'] = $uid; 
    420                                                                         break; 
    421          
    422                                                         case "description" : 
    423                                                                         // SERPRO 
    424                                                                         // parte antes do arroba;  
    425                                                                         $result[$i]['uid'] = $result[$i]['description'];                                                                                 
    426                                                                         break; 
    427                                                 } 
    428                                         } 
    429                                 } 
    430                         } 
    431                 } 
     410                } 
     411                 
    432412                return $result; 
    433413        } 
Note: See TracChangeset for help on using the changeset viewer.