Ignore:
Timestamp:
07/18/08 11:36:30 (16 years ago)
Author:
niltonneto
Message:

Alterações do Desenvolvedor.

File:
1 edited

Legend:

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

    r317 r355  
    77function ldapRebind($ldap_connection, $ldap_url) 
    88{ 
     9        // Enquanto estivermos utilizando referral na arvore ldap, teremos que continuar a utilizar o usuário sistemas:expresso. 
     10        // Depois, quando não existir mais referral, não existirá a necessidade de ldapRebind. 
     11        //ldap_bind($ldap_connection, $GLOBALS['phpgw_info']['server']['ldap_master_root_dn'], $GLOBALS['phpgw_info']['server']['ldap_master_root_pw']); 
    912        if ( ($_SESSION['phpgw_info']['expresso']['cc_ldap_server']['acc'] != '') && ($_SESSION['phpgw_info']['expresso']['cc_ldap_server']['pw'] != '') ) 
    1013        { 
     
    2023        var $manager_contexts; 
    2124         
    22         function ldap_functions(){ 
     25        function ldap_functions(){               
    2326                $GLOBALS['phpgw_info']['server'] = $_SESSION['phpgw_info']['expresso']['server']; 
    2427                $this->current_config = $_SESSION['phpgw_info']['expresso']['expressoAdmin']; 
    2528                $common = new common(); 
    26                 $this->ldap = $common->ldapConnect(); 
     29                 
     30                if ( (!empty($GLOBALS['phpgw_info']['server']['ldap_master_host'])) && 
     31                         (!empty($GLOBALS['phpgw_info']['server']['ldap_master_root_dn'])) && 
     32                         (!empty($GLOBALS['phpgw_info']['server']['ldap_master_root_pw'])) ) 
     33                { 
     34                        $this->ldap = $common->ldapConnect($GLOBALS['phpgw_info']['server']['ldap_master_host'], 
     35                                                                                           $GLOBALS['phpgw_info']['server']['ldap_master_root_dn'], 
     36                                                                                           $GLOBALS['phpgw_info']['server']['ldap_master_root_pw']); 
     37                } 
     38                else 
     39                { 
     40                        $this->ldap = $common->ldapConnect(); 
     41                } 
    2742                 
    2843                $this->functions = new functions; 
     
    3146        } 
    3247         
    33         /* ldap connection following referals and using Contac Center config*/ 
     48        /* expressoAdmin: email lists : deve utilizar o ldap Host Master com o usuario e senha do CC*/ 
     49        /* ldap connection following referrals and using Master config, from setup */ 
    3450        function ldapMasterConnect() 
    3551        { 
    36                 if ( (is_array($_SESSION['phpgw_info']['expresso']['cc_ldap_server'])) && ($ldap_connection = ldap_connect($_SESSION['phpgw_info']['expresso']['cc_ldap_server']['host'])) ) 
     52                /* 
     53                $common = new common(); 
     54                if ( (!empty($GLOBALS['phpgw_info']['server']['ldap_master_host'])) && 
     55                         (!empty($GLOBALS['phpgw_info']['server']['ldap_master_root_dn'])) && 
     56                         (!empty($GLOBALS['phpgw_info']['server']['ldap_master_root_pw'])) ) 
     57                { 
     58                        $ldap_connection = ldap_connect($GLOBALS['phpgw_info']['server']['ldap_master_host']); 
     59                        ldap_set_option($ldap_connection, LDAP_OPT_PROTOCOL_VERSION, 3); 
     60                        ldap_set_option($ldap_connection, LDAP_OPT_REFERRALS, true); 
     61                        ldap_set_rebind_proc($ldap_connection, ldapRebind); 
     62                        ldap_bind($ldap_connection, $GLOBALS['phpgw_info']['server']['ldap_master_root_dn'], $GLOBALS['phpgw_info']['server']['ldap_master_root_pw']); 
     63                } 
     64                else 
     65                { 
     66                        $ldap_connection = $common->ldapConnect($GLOBALS['phpgw_info']['server']['ldap_host'], 
     67                                                                                           $GLOBALS['phpgw_info']['server']['ldap_root_dn'], 
     68                                                                                           $GLOBALS['phpgw_info']['server']['ldap_root_pw'], true); 
     69                } 
     70                 
     71                // If success, return follow_referral connection. Else, return normal connection. 
     72                if ($ldap_connection) 
     73                        return $ldap_connection; 
     74                else 
     75                        return $this->ldap; 
     76                */ 
     77                 
     78                if ( (!empty($GLOBALS['phpgw_info']['server']['ldap_master_host'])) && ($ldap_connection = ldap_connect($GLOBALS['phpgw_info']['server']['ldap_master_host'])) ) 
    3779                { 
    3880                        ldap_set_option($ldap_connection, LDAP_OPT_PROTOCOL_VERSION, 3); 
     
    101143                $mail = $params['mail']; 
    102144                $mailalternateaddress = $params['mailalternateaddress']; 
     145                $cpf = $params['cpf']; 
    103146                                 
    104147                if ($_SESSION['phpgw_info']['expresso']['global_denied_users'][$uid]) 
     
    265308                } 
    266309 
     310                //Begin: Check CPF 
     311                if (!empty($cpf)) 
     312                { 
     313                        if (!$this->functions->checkCPF($cpf)) 
     314                        { 
     315                                $result['status'] = false; 
     316                                $result['msg'] = $this->functions->lang('Field CPF is invalid') . '.'; 
     317                                return $result; 
     318                        } 
     319                        else 
     320                        { 
     321                                $local_ldap_connection = ldap_connect($GLOBALS['phpgw_info']['server']['ldap_host']); 
     322                                if ($ldap_connection) 
     323                                { 
     324                                        ldap_set_option($local_ldap_connection, LDAP_OPT_PROTOCOL_VERSION, 3); 
     325                                        ldap_set_option($local_ldap_connection, LDAP_OPT_REFERRALS, false); 
     326                                        ldap_bind($local_ldap_connection, $GLOBALS['phpgw_info']['server']['ldap_root_dn'], $GLOBALS['phpgw_info']['server']['ldap_root_pw']); 
     327                                } 
     328                                else 
     329                                { 
     330                                        $result['status'] = false; 
     331                                        $result['msg'] = 'Falha na conexao com o ldap.'; 
     332                                        return $result; 
     333                                } 
     334                                 
     335                                $filter = "(&(phpgwAccountType=u)(cpf=$cpf))"; 
     336                                $justthese = array("cn","uid"); 
     337                                $search = ldap_search($local_ldap_connection, $context, $filter, $justthese); 
     338                                $entries = ldap_get_entries($local_ldap_connection,$search); 
     339                                 
     340                                if ( ($entries['count'] == 1) && (strcasecmp($uid, $entries[0]['uid'][0]) == 0) ) 
     341                                {} 
     342                                else 
     343                                { 
     344                                        if ($entries['count'] > 0) 
     345                                        { 
     346                                                $result['question'] = $this->functions->lang('Field CPF used by') . ":\n"; 
     347                                                for ($i=0; $i<$entries['count']; $i++) 
     348                                                { 
     349                                                        if (strcasecmp($uid, $entries[$i]['uid'][0]) != 0) 
     350                                                                $result['question'] .= "- " . $entries[$i]['cn'][0] . "\n"; 
     351                                                } 
     352                                                $result['question'] .= $this->functions->lang("Do you want to continue anyway") . "?"; 
     353                                                return $result; 
     354                                        } 
     355                                } 
     356                                ldap_close($local_ldap_connection); 
     357                        } 
     358                } 
     359                else if ($this->current_config['expressoAdmin_cpf_obligation']) 
     360                { 
     361                        $result['status'] = false; 
     362                        $result['msg'] = $this->functions->lang('Field CPF must be completed') . '.'; 
     363                        return $result; 
     364                } 
     365                //End: Check CPF 
     366 
    267367                return $result; 
    268368        } 
     
    13571457                 
    13581458                $return['status'] = true; 
    1359                  
     1459                $return['msg'] = ""; 
     1460                                 
    13601461                // GROUPS 
    13611462                $attrs = array(); 
    1362                 $attrs['memberUid'] = $user_info['uid']; 
     1463                $attrs['memberuid'] = $user_info['uid']; 
     1464                 
    13631465                if (count($user_info['groups_info'])) 
    13641466                { 
     
    13711473                        $entry = ldap_get_entries($this->ldap, $search); 
    13721474                                $dn = $entry[0]['dn']; 
    1373                          
     1475 
    13741476                                if (!@ldap_mod_del($this->ldap, $dn, $attrs)) 
    13751477                                { 
    13761478                                        $return['status'] = false; 
    1377                                         $return['msg'] .= 'Erro em ldap_funcitons->delete_user, grupos: ' . ldap_error($this->ldap); 
     1479                                        $return['msg'] .= "Erro em ldap_functions->delete_user from group ($dn): " . ldap_error($this->ldap); 
    13781480                                } 
    13791481                        } 
Note: See TracChangeset for help on using the changeset viewer.