Changeset 355 for trunk/expressoAdmin1_2/inc/class.ldap_functions.inc.php
- Timestamp:
- 07/18/08 11:36:30 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/expressoAdmin1_2/inc/class.ldap_functions.inc.php
r317 r355 7 7 function ldapRebind($ldap_connection, $ldap_url) 8 8 { 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']); 9 12 if ( ($_SESSION['phpgw_info']['expresso']['cc_ldap_server']['acc'] != '') && ($_SESSION['phpgw_info']['expresso']['cc_ldap_server']['pw'] != '') ) 10 13 { … … 20 23 var $manager_contexts; 21 24 22 function ldap_functions(){ 25 function ldap_functions(){ 23 26 $GLOBALS['phpgw_info']['server'] = $_SESSION['phpgw_info']['expresso']['server']; 24 27 $this->current_config = $_SESSION['phpgw_info']['expresso']['expressoAdmin']; 25 28 $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 } 27 42 28 43 $this->functions = new functions; … … 31 46 } 32 47 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 */ 34 50 function ldapMasterConnect() 35 51 { 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'])) ) 37 79 { 38 80 ldap_set_option($ldap_connection, LDAP_OPT_PROTOCOL_VERSION, 3); … … 101 143 $mail = $params['mail']; 102 144 $mailalternateaddress = $params['mailalternateaddress']; 145 $cpf = $params['cpf']; 103 146 104 147 if ($_SESSION['phpgw_info']['expresso']['global_denied_users'][$uid]) … … 265 308 } 266 309 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 267 367 return $result; 268 368 } … … 1357 1457 1358 1458 $return['status'] = true; 1359 1459 $return['msg'] = ""; 1460 1360 1461 // GROUPS 1361 1462 $attrs = array(); 1362 $attrs['memberUid'] = $user_info['uid']; 1463 $attrs['memberuid'] = $user_info['uid']; 1464 1363 1465 if (count($user_info['groups_info'])) 1364 1466 { … … 1371 1473 $entry = ldap_get_entries($this->ldap, $search); 1372 1474 $dn = $entry[0]['dn']; 1373 1475 1374 1476 if (!@ldap_mod_del($this->ldap, $dn, $attrs)) 1375 1477 { 1376 1478 $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); 1378 1480 } 1379 1481 }
Note: See TracChangeset
for help on using the changeset viewer.