Changeset 1600 for trunk/contactcenter/inc/class.bo_ldap_manager.inc.php
- Timestamp:
- 11/06/09 10:11:14 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/contactcenter/inc/class.bo_ldap_manager.inc.php
r1419 r1600 45 45 'acc' => $data['cc_ldap_browse_dn0'], 46 46 'pw' => $data['cc_ldap_pw0'], 47 'obj' => ' phpgwAccount',47 'obj' => 'inetOrgPerson', 48 48 'branch' => strtolower('ou'), 49 49 'visible' => $data['cc_ldap_query_automatic'] … … 83 83 /* 84 84 * @function get_external_ldap_sources 85 * @author M ário César Kolling <mario.kolling@serpro.gov.br>85 * @author Mï¿œrio Cï¿œsar Kolling <mario.kolling@serpro.gov.br> 86 86 * @abstract returns an array with the external sources 87 87 * @return (array) the external sources … … 104 104 105 105 $op_iop = array( 106 'contact.uidnumber' 106 'contact.uidnumber' => array('uidNumber'), 107 107 'contact.id_contact' => array('dn'), 108 108 'contact.photo' => array('jpegPhoto'), … … 123 123 'contact.object_class' => array('objectClass'), 124 124 'contact.business_info.title' => array('title'), 125 'contact.business_info.department' => array('ou'), 126 'contact.company.company_name' => array('o'), 125 'contact.business_info.department' => array('ou'), // Setor do empregado... 126 'contact.business_info.empNumber' => array('employeeNumber'), // Matricula do empregado 127 128 'contact.business_info.celPhone' => array('mobile'), // Celular empresarial do empregado 129 130 'contact.company.company_name' => array('o'), 127 131 'contact.company.company_notes' => array('businessCategory'), 128 132 … … 162 166 'email' => array('mail'), 163 167 'phone' => array('telephoneNumber'), 164 'mobile' => array('mobile'), 165 'pager' => array('pager'), 166 'fax' => array('facsimileTelephoneNumber'), 168 // 'mobile' => array('mobile'), 169 // 'pager' => array('pager'), // idem ao comentario abaixo, do atributo fax; 170 // 'fax' => array('facsimileTelephoneNumber'), //linha comentada para nao trazer 171 // o atributo fax do Ldap; correcao temporaria para nao exibir o fax no ContactCenter 172 //(estava sobrepondo o telefone do usuario) 173 167 174 'telex' => array('telexNumber') 168 175 ), … … 174 181 /* 175 182 * @function get_external_ldap_fields_association 176 * @author M ário César Kolling <mario.kolling@serpro.gov.br>183 * @author Mï¿œrio Cï¿œsar Kolling <mario.kolling@serpro.gov.br> 177 184 * @abstract get the fields association for an external ldap_source 178 185 * @return an array with attribute mappings … … 187 194 /* 188 195 * @function test_connection 189 * @author M ário César Kolling <mario.kolling@serpro.gov.br>196 * @author Mï¿œrio Cï¿œsar Kolling <mario.kolling@serpro.gov.br> 190 197 * @abstract Test if we can bind to a ldap server in a reasonable time 191 198 * @param (string) $host ldap server's hostname … … 250 257 } 251 258 252 $ldap = $GLOBALS['phpgw']->common->ldapConnect($this->srcs[$id_source]['host'], $this->srcs[$id_source]['acc'],$this->srcs[$id_source]['pw'], true);259 $ldap = $GLOBALS['phpgw']->common->ldapConnect($this->srcs[$id_source]['host'], $this->srcs[$id_source]['acc'],$this->srcs[$id_source]['pw'], false); 253 260 if (!$ldap) 254 261 { … … 272 279 @function get_external_ldap_tree 273 280 @abstract Returns the LDAP external tree corresponding to the specified level 274 @author M ário César Kolling <mario.kolling@serpro.gov.br>281 @author Mï¿œrio Cï¿œsar Kolling <mario.kolling@serpro.gov.br> 275 282 @param (integer) $id_source The ID of the external LDAP source 276 283 @param (string) $context The context to be used as root branch … … 285 292 include(PHPGW_INCLUDE_ROOT . '/contactcenter/setup/external_catalogs.inc.php' ); 286 293 //include('external_catalogs.inc.php' ); 287 294 288 295 if (!$external_srcs[$id_source]) 289 296 { 290 297 return null; 291 298 } 292 299 293 300 // calls test_connection first. If succeeded continue, return error message otherwise. 294 301 if (!($response = $this->test_connection($external_srcs[$id_source]['host'], $external_srcs[$id_source]['acc'], $external_srcs[$id_source]['pw'], 10))) … … 411 418 else 412 419 return false; 413 414 415 420 } 416 421 … … 441 446 { 442 447 /* 443 * Esta opera ção resolve o problema causado pela conversão de caracteres acentuados realizada444 * pela fun ção ldap_explode_dn().448 * Esta operaᅵᅵo resolve o problema causado pela conversï¿œo de caracteres acentuados realizada 449 * pela funᅵᅵo ldap_explode_dn(). 445 450 */ 446 451 … … 450 455 function get_ldap_tree_level($id_source, $resource, $context, $objectClass, $branch_dn, $external = 0) 451 456 { 452 457 if(strstr($context, "ldap://")){ 458 $refer_context = str_replace("??base","",preg_replace('!^(ldap://[^/]+)/(.*$)!', '\\2', $context)); 459 $host = preg_replace('!^(ldap://[^/]+)/.*$!', '\\1', $context); 460 $resource = ldap_connect($host); 461 ldap_bind($resource); 462 } 463 453 464 /* 454 465 * TODO: Search timeouts 455 466 */ 456 457 $dn_parts = ldap_explode_dn( $context,1);467 468 $dn_parts = ldap_explode_dn(($refer_context ? $refer_context : $context),1); 458 469 //$filter = '(!(objectClass='.$objectClass.'))'; 459 470 // Don't show OU's whith phpgwAccountVisible equal to '-1' … … 468 479 // and whose attribute phpgwAccountVisible value is different from -1 469 480 $filter = '(&(!(objectClass='.$objectClass.')) (!(phpgwAccountVisible=-1)))'; 470 $context = preg_replace("/dc=(.*)/i",$this->srcs[$id_source]['dn'],$context); 471 } 472 473 $result_res = @ldap_list($resource, $context, $filter, array(), 0, 0); 474 if (!$result_res) 481 } 482 $result_res = @ldap_list($resource, ($refer_context ? $refer_context : $context), $filter, array(), 0, 0); 483 @ldap_sort($resource, $result_res, 'ou'); 484 485 // Timeouts commented out 486 /* 487 if ($result_res === false) 488 { 475 489 return null; 476 477 @ldap_sort($resource, $result_res, 'ou'); 490 } 491 */ 492 478 493 $count = ldap_count_entries($resource,$result_res); 479 494 480 495 if ( $count == 0 ) 481 496 { 482 497 $filter = '(objectClass='.$objectClass.')'; 483 498 // Get only one attribute of the source's objectClass 484 $result_res2 = @ldap_list($resource, $context, $filter, Array('cn'), 0, 1); 485 if (!$result_res2) 486 return null; 487 499 $result_res2 = @ldap_list($resource, ($refer_context ? $refer_context : $context), $filter, Array('cn'), 0, 1); 488 500 $entries_count = ldap_count_entries($resource, $result_res2); 489 501 … … 509 521 } 510 522 } 511 523 512 524 $sub_branch_found = false; 513 525 $i = 0; … … 521 533 list($group) = explode('=',$dn_parts_full[0]); 522 534 523 //Faz a compara ção do branch como case insensitive535 //Faz a comparaᅵᅵo do branch como case insensitive 524 536 if (strtolower($group) == strtolower($branch_dn) or $branch_dn === 'all') 525 537 { … … 527 539 'name' => $this->translate_accentuation($dn_parts_1[0]), 528 540 'type' => 'unknown', 529 'value' => $dn,541 'value' => ($refer_context ? $host."/" : "").$dn, 530 542 'sub_branch' => false 531 543 ); … … 534 546 $i++; 535 547 } 536 548 549 if(! $refer_context) { 550 $array_referral = $this -> get_ldap_sub_branches_referrals($resource, $context,'(objectClass=organizationalUnit)'); 551 for($z = 0; $z < count($array_referral); $z++) { 552 $tree['sub_branch'][$i++] = $array_referral[$z]; 553 } 554 } 555 537 556 $filter = 'objectClass='.$objectClass; 538 $result_res2 = @ldap_list($resource, $context, $filter, Array('cn'), 0, 1);557 $result_res2 = @ldap_list($resource, ($refer_context ? $refer_context : $context), $filter, Array('cn'), 0, 1); 539 558 $entries_count = ldap_count_entries($resource, $result_res2); 540 559
Note: See TracChangeset
for help on using the changeset viewer.