Ignore:
Timestamp:
09/21/09 15:56:22 (15 years ago)
Author:
alexandrecorreia
Message:

Ticket #649 - Correção para liberar organização ( sub-ous ) por grupo.

File:
1 edited

Legend:

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

    r1160 r1438  
    5151                 
    5252                $GLOBALS['phpgw_info']['server']['ldap_version3'] = true; 
    53  
    54                 $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 ); 
    5558        } 
    5659         
    5760        private final function ldapRoot() 
    5861        { 
    59                 $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']; 
    60                 $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']; 
    61                 $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']; 
    62                 $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']; 
    6366 
    6467                $this->ldapConn(); 
     
    146149                if( $this->ldap ) 
    147150                { 
    148                         $filter="ou=*";          
    149                         $justthese = array("ou"); 
    150                         $search = ldap_search($this->ldap,$this->ldap_context,$filter,$justthese);                       
    151                         $entry = ldap_get_entries($this->ldap, $search); 
    152                 } 
    153  
    154                 foreach($entry as $tmp) 
    155                         if($tmp['ou'][0] != "") 
    156                                 $result_org[] = $tmp['ou'][0];   
    157  
    158                 return $result_org; 
    159         } 
    160  
     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        } 
    161199 
    162200        public final function getUsersLdapCatalog( $search ) 
Note: See TracChangeset for help on using the changeset viewer.