Ignore:
Timestamp:
08/14/08 11:45:39 (16 years ago)
Author:
niltonneto
Message:

Modificações referente a opção de configurar um ldap_master
no setup do Expresso, usado somente para escrita.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/expressoAdmin1_2/inc/class.sosectors.inc.php

    r32 r396  
    1313        { 
    1414                var $functions; 
     15                var $ldap_connection; 
    1516                 
    1617                function sosectors() 
    1718                { 
    1819                        $this->functions = createobject('expressoAdmin1_2.functions'); 
     20                         
     21                        if ( (!empty($GLOBALS['phpgw_info']['server']['ldap_master_host'])) && 
     22                                 (!empty($GLOBALS['phpgw_info']['server']['ldap_master_root_dn'])) && 
     23                                 (!empty($GLOBALS['phpgw_info']['server']['ldap_master_root_pw'])) ) 
     24                        { 
     25                                $this->ldap_connection = $GLOBALS['phpgw']->common->ldapConnect($GLOBALS['phpgw_info']['server']['ldap_master_host'], 
     26                                                                                                   $GLOBALS['phpgw_info']['server']['ldap_master_root_dn'], 
     27                                                                                                   $GLOBALS['phpgw_info']['server']['ldap_master_root_pw']); 
     28                        } 
     29                        else 
     30                        { 
     31                                $this->ldap_connection = $GLOBALS['phpgw']->common->ldapConnect(); 
     32                        } 
    1933                } 
    2034                 
    2135                function exist_sector_name($sector_name, $context) 
    2236                { 
    23                         $connection = $GLOBALS['phpgw']->common->ldapConnect(); 
    24                         $search = ldap_list($connection, $context, "ou=" . $sector_name); 
    25                         $result = ldap_get_entries($connection, $search); 
     37                        $search = ldap_list($this->ldap_connection, $context, "ou=" . $sector_name); 
     38                        $result = ldap_get_entries($this->ldap_connection, $search); 
    2639                         
    2740                        if ($result['count'] == 0) 
     
    3346                function write_ldap($dn, $info) 
    3447                { 
    35                         $connection = $GLOBALS['phpgw']->common->ldapConnect(); 
    36                          
    37                         if (ldap_add($connection, $dn, $info)) 
     48                        if (ldap_add($this->ldap_connection, $dn, $info)) 
    3849                        { 
    3950                                //Escreve no log 
    4051                                $this->functions->write_log2($GLOBALS['phpgw']->accounts->data['account_lid'], 'write in ldap', $dn,'','',''); 
    41                                 ldap_close($connection); 
     52                                ldap_close($this->ldap_connection); 
    4253                                return true; 
    4354                        } 
     
    4556                        { 
    4657                                echo 'Erro na escrita no LDAP, funcao write_ldap'; 
    47                                 ldap_close($connection); 
     58                                ldap_close($this->ldap_connection); 
    4859                                return false; 
    4960                        } 
     
    5263                function get_sector_users($context) 
    5364                { 
    54                         $connection = $GLOBALS['phpgw']->common->ldapConnect(); 
    5565                        $justthese = array("cn", "uidNumber", "uid"); 
    5666                        $filter="(&(phpgwAccountType=u)(uid=*))"; 
    57                         $search=ldap_search($connection, $context, $filter, $justthese); 
    58                         $result = ldap_get_entries($connection, $search); 
     67                        $search=ldap_search($this->ldap_connection, $context, $filter, $justthese); 
     68                        $result = ldap_get_entries($this->ldap_connection, $search); 
    5969                        return $result; 
    6070                } 
     
    6272                function get_sector_groups($context) 
    6373                { 
    64                         $connection = $GLOBALS['phpgw']->common->ldapConnect(); 
    6574                        $justthese = array("cn", "gidnumber"); 
    6675                        $filter="(&(phpgwAccountType=g)(cn=*))"; 
    67                         $search=ldap_search($connection, $context, $filter, $justthese); 
    68                         $result = ldap_get_entries($connection, $search); 
     76                        $search=ldap_search($this->ldap_connection, $context, $filter, $justthese); 
     77                        $result = ldap_get_entries($this->ldap_connection, $search); 
    6978                        return $result; 
    7079                } 
     
    7281                function get_sector_subsectors($context) 
    7382                { 
    74                         $connection = $GLOBALS['phpgw']->common->ldapConnect(); 
    7583                        $justthese = array("ou"); 
    7684                        $filter="(objectClass=organizationalUnit)"; 
    77                         $search=ldap_search($connection, $context, $filter, $justthese); 
    78                         $result = ldap_get_entries($connection, $search); 
     85                        $search=ldap_search($this->ldap_connection, $context, $filter, $justthese); 
     86                        $result = ldap_get_entries($this->ldap_connection, $search); 
    7987                        return $result; 
    8088                } 
     
    101109                function get_info($context) 
    102110                { 
    103                         $connection = $GLOBALS['phpgw']->common->ldapConnect(); 
    104111                        $filter="(objectClass=organizationalUnit)"; 
    105                         $search=ldap_search($connection, $context, $filter); 
    106                         $result = ldap_get_entries($connection, $search); 
     112                        $search=ldap_search($this->ldap_connection, $context, $filter); 
     113                        $result = ldap_get_entries($this->ldap_connection, $search); 
    107114                        return $result; 
    108115                } 
     
    110117                function add_attribute($dn, $info) 
    111118                { 
    112                         $connection = $GLOBALS['phpgw']->common->ldapConnect(); 
    113                          
    114                         if (ldap_mod_add($connection, $dn, $info)) 
     119                        if (ldap_mod_add($this->ldap_connection, $dn, $info)) 
    115120                        { 
    116                                 ldap_close($connection); 
     121                                ldap_close($this->ldap_connection); 
    117122                                return true; 
    118123                        } 
    119124                        else 
    120125                        { 
    121                                 echo 'Erro na escrita no LDAP, funcao add_attribute: ' . ldap_error($connection); 
    122                                 ldap_close($connection); 
     126                                echo 'Erro na escrita no LDAP, funcao add_attribute: ' . ldap_error($this->ldap_connection); 
     127                                ldap_close($this->ldap_connection); 
    123128                                return false; 
    124129                        } 
     
    127132                function remove_attribute($dn, $info) 
    128133                { 
    129                         $connection = $GLOBALS['phpgw']->common->ldapConnect(); 
    130                          
    131                         if (ldap_mod_del($connection, $dn, $info)) 
     134                        if (ldap_mod_del($this->ldap_connection, $dn, $info)) 
    132135                        { 
    133                                 ldap_close($connection); 
     136                                ldap_close($this->ldap_connection); 
    134137                                return true; 
    135138                        } 
    136139                        else 
    137140                        { 
    138                                 echo 'Erro na escrita no LDAP, funcao remove_attribute: ' . ldap_error($connection); 
    139                                 ldap_close($connection); 
     141                                echo 'Erro na escrita no LDAP, funcao remove_attribute: ' . ldap_error($this->ldap_connection); 
     142                                ldap_close($this->ldap_connection); 
    140143                                return false; 
    141144                        } 
    142145                } 
    143  
    144146        } 
    145147?> 
Note: See TracChangeset for help on using the changeset viewer.