Changeset 4313


Ignore:
Timestamp:
05/10/11 15:20:49 (13 years ago)
Author:
niltonneto
Message:

Ticket #222 - Modificado implementação que lista Referrals, sem ldap_next_reference().

Location:
branches/2.2/contactcenter/inc
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/2.2/contactcenter/inc/class.bo_global_ldap_catalog.inc.php

    r4205 r4313  
    151151            // Find objects where 'mail' attribute is not null. 
    152152                        $filter = "(&".$filter."(mail=*))"; 
    153  
    154                         if(strstr($this->src_info['context'], "ldap://")) { 
    155                                 $refer_context  = str_replace("??base","",preg_replace('!^(ldap://[^/]+)/(.*$)!', '\\2', $this->src_info['context'])); 
    156                                 $host   = preg_replace('!^(ldap://[^/]+)/.*$!', '\\1', $this->src_info['context']); 
    157                                 $this->src_info['host'] = $host; 
    158                         } 
    159                         if($refer_context || "ou" === strtolower(substr($this->src_info['context'], 0, 2))) 
    160                         { 
    161                                 $followReferral = false; 
    162                         } 
    163                         elseif(trim($rules[4]['value']) != "inetOrgPerson") 
    164                         { 
    165                                 $followReferral = true; 
    166                         } 
    167                         else 
    168                         {                                
    169                                 return false; 
    170                         } 
    171                          
    172                         $ldap = $GLOBALS['phpgw']->common->ldapConnect($this->src_info['host'], $this->src_info['acc'], $this->src_info['pw'], $followReferral); 
    173                         $result_r = $recursive ? ldap_search($ldap ,($refer_context  ? $refer_context  : $this->src_info['context']), $filter, $fields, 0, $this->src_info['max_results']) : 
    174                                                 ldap_list($ldap , ($refer_context  ? $refer_context  : $this->src_info['context']), $filter, $fields, 0, $this->src_info['max_results']); 
     153                         
     154                        $ldap = $GLOBALS['phpgw']->common->ldapConnect($this->src_info['host'], $this->src_info['acc'], $this->src_info['pw'], true); 
     155                        $result_r = $recursive ? ldap_search($ldap , $this->src_info['context'], $filter, $fields, 0, $this->src_info['max_results']) : 
     156                                                ldap_list($ldap , $this->src_info['context'], $filter, $fields, 0, $this->src_info['max_results']); 
    175157 
    176158                        if (!$result_r) 
  • branches/2.2/contactcenter/inc/class.bo_ldap_manager.inc.php

    r4241 r4313  
    269269                        } 
    270270                         
    271                         $ldap = $GLOBALS['phpgw']->common->ldapConnect($this->srcs[$id_source]['host'], $this->srcs[$id_source]['acc'],$this->srcs[$id_source]['pw'], false); 
     271                        $ldap = $GLOBALS['phpgw']->common->ldapConnect($this->srcs[$id_source]['host'], $this->srcs[$id_source]['acc'],$this->srcs[$id_source]['pw'], true); 
    272272                        if (!$ldap) 
    273273                        { 
     
    467467                function get_ldap_tree_level($id_source, $resource, $context, $objectClass, $branch_dn, $external = 0) 
    468468                { 
    469                         if(strstr($context, "ldap://")){ 
    470                                 $refer_context = str_replace("??base","",preg_replace('!^(ldap://[^/]+)/(.*$)!', '\\2', $context)); 
    471                                 $host   = preg_replace('!^(ldap://[^/]+)/.*$!', '\\1', $context); 
    472                                 $resource = ldap_connect($host); 
    473                                 ldap_bind($resource); 
    474                         } 
    475  
    476469                        /* 
    477470                         * TODO: Search timeouts 
    478471                         */ 
    479472 
    480                         $dn_parts = ldap_explode_dn(($refer_context ? $refer_context : $context),1); 
     473                        $dn_parts = ldap_explode_dn($context,1); 
    481474                        //$filter = '(!(objectClass='.$objectClass.'))'; 
    482475                        // Don't show OU's whith phpgwAccountVisible equal to '-1' 
     
    491484                                // and whose attribute phpgwAccountVisible value is different from -1 
    492485                                $filter = '(&(!(objectClass='.$objectClass.')) (!(phpgwAccountVisible=-1)))'; 
    493                         } 
    494                         $result_res = @ldap_list($resource,  ($refer_context ? $refer_context : $context), $filter, array(), 0, 0); 
     486                                $context = preg_replace("/dc=(.*)/i",$this->srcs[$id_source]['dn'],$context);    
     487                        } 
     488                        $result_res = @ldap_list($resource,  $context, $filter, array(), 0, 0); 
    495489                        @ldap_sort($resource, $result_res, 'ou'); 
    496490 
     
    509503                                $filter = '(objectClass='.$objectClass.')'; 
    510504                                // Get only one attribute of the source's objectClass 
    511                                 $result_res2 = @ldap_list($resource, ($refer_context ? $refer_context : $context), $filter, Array('cn'), 0, 1); 
     505                                $result_res2 = @ldap_list($resource, $context, $filter, Array('cn'), 0, 1); 
    512506                                $entries_count = ldap_count_entries($resource, $result_res2); 
    513507 
     
    551545                                                'name'  => $this->translate_accentuation($dn_parts_1[0]), 
    552546                                                'type'  => 'unknown', 
    553                                                 'value' =>  ($refer_context ? $host."/" : "").$dn, 
     547                                                'value' =>  $dn, 
    554548                                                'sub_branch' => false 
    555549                                        ); 
     
    558552                                $i++; 
    559553                        } 
    560  
    561                         if(! $refer_context) { 
    562                                 $array_referral = $this -> get_ldap_sub_branches_referrals($resource, $context,'(objectClass=organizationalUnit)'); 
    563                                 for($z = 0; $z < count($array_referral); $z++) { 
    564                                         $tree['sub_branch'][$i++] = $array_referral[$z]; 
    565                                 } 
    566                         } 
    567  
    568554                        $filter = 'objectClass='.$objectClass; 
    569                         $result_res2 = @ldap_list($resource, ($refer_context ? $refer_context : $context), $filter, Array('cn'), 0, 1); 
     555                        $result_res2 = @ldap_list($resource, $context, $filter, Array('cn'), 0, 1); 
    570556                        $entries_count = ldap_count_entries($resource, $result_res2); 
    571557 
Note: See TracChangeset for help on using the changeset viewer.