Changeset 0102742 in github
- Timestamp:
- Sep 21, 2009 7:50:53 AM (4 years ago)
- Branches:
- master, HEAD, courier-fix, dev-browser-capabilities, pdo, release-0.6, release-0.7, release-0.8
- Children:
- 3e2bc6a
- Parents:
- 104a14d
- Files:
-
- 4 edited
-
CHANGELOG (modified) (1 diff)
-
config/main.inc.php.dist (modified) (1 diff)
-
program/include/rcmail.php (modified) (2 diffs)
-
program/include/rcube_ldap.php (modified) (17 diffs)
Legend:
- Unmodified
- Added
- Removed
-
CHANGELOG
r587444f r0102742 2 2 =========================== 3 3 4 - Added 'ldap_debug' option 4 5 - Fix "Empty startup greeting" bug (#1486085) 5 6 - Fix setting user name in 'new_user_identity' plugin (#1486137) -
config/main.inc.php.dist
r4d97074 r0102742 130 130 // Log IMAP conversation to <log_dir>/imap or to syslog 131 131 $rcmail_config['imap_debug'] = false; 132 133 // Log LDAP conversation to <log_dir>/ldap or to syslog 134 $rcmail_config['ldap_debug'] = false; 132 135 133 136 // Log SMTP conversation to <log_dir>/smtp or to syslog -
program/include/rcmail.php
rbdab2c5 r0102742 267 267 } 268 268 else if ($id && $ldap_config[$id]) { 269 $contacts = new rcube_ldap($ldap_config[$id] );269 $contacts = new rcube_ldap($ldap_config[$id], $this->config->get('ldap_debug'), $this->config->mail_domain($_SESSION['imap_host'])); 270 270 } 271 271 else if ($id === '0') { … … 276 276 foreach ($ldap_config as $id => $prop) { 277 277 if (!$writeable || $prop['writable']) { 278 $contacts = new rcube_ldap($prop );278 $contacts = new rcube_ldap($prop, $this->config->get('ldap_debug'), $this->config->mail_domain($_SESSION['imap_host'])); 279 279 break; 280 280 } -
program/include/rcube_ldap.php
r2b82072 r0102742 35 35 var $ldap_result = null; 36 36 var $sort_col = ''; 37 var $mail_domain = ''; 38 var $debug = false; 37 39 38 40 /** public properties */ … … 47 49 * Object constructor 48 50 * 49 * @param array LDAP connection properties 51 * @param array LDAP connection properties 52 * @param boolean Enables debug mode 53 * @param string Current user mail domain name 50 54 * @param integer User-ID 51 55 */ 52 function __construct($p )56 function __construct($p, $debug=false, $mail_domain=NULL) 53 57 { 54 58 $this->prop = $p; … … 66 70 67 71 $this->sort_col = $p['sort']; 72 $this->debug = $debug; 73 $this->mail_domain = $mail_domain; 68 74 69 75 $this->connect(); … … 92 98 foreach ($this->prop['hosts'] as $host) 93 99 { 100 $this->_debug("C: Connect [$host".($this->prop['port'] ? ':'.$this->prop['port'] : '')."]"); 101 94 102 if ($lc = @ldap_connect($host, $this->prop['port'])) 95 103 { … … 98 106 continue; 99 107 108 $this->_debug("S: OK"); 109 100 110 ldap_set_option($lc, LDAP_OPT_PROTOCOL_VERSION, $this->prop['ldap_version']); 101 111 $this->prop['host'] = $host; … … 103 113 break; 104 114 } 115 $this->_debug("S: NOT OK"); 105 116 } 106 117 … … 153 164 } 154 165 166 $this->_debug("C: Bind [dn: $dn] [pass: $pass]"); 167 155 168 if (@ldap_bind($this->conn, $dn, $pass)) { 169 $this->_debug("S: OK"); 156 170 return true; 157 171 } 172 173 $this->_debug("S: ".ldap_error($this->conn)); 158 174 159 175 raise_error(array( … … 174 190 if ($this->conn) 175 191 { 192 $this->_debug("C: Close"); 176 193 ldap_unbind($this->conn); 177 194 $this->conn = null; … … 389 406 if ($this->conn && $dn) 390 407 { 408 $this->_debug("C: Read [dn: ".base64_decode($dn)."] [(objectclass=*)]"); 409 391 410 if ($this->ldap_result = @ldap_read($this->conn, base64_decode($dn), '(objectclass=*)', array_values($this->fieldmap))) 392 411 $entry = ldap_first_entry($this->conn, $this->ldap_result); 412 else 413 $this->_debug("S: ".ldap_error($this->conn)); 393 414 394 415 if ($entry && ($rec = ldap_get_attributes($this->conn, $entry))) 395 416 { 417 $this->_debug("S: OK"); 418 396 419 $rec = array_change_key_case($rec, CASE_LOWER); 397 420 … … 438 461 // Build the new entries DN. 439 462 $dn = $this->prop['LDAP_rdn'].'='.$newentry[$this->prop['LDAP_rdn']].','.$this->prop['base_dn']; 463 464 $this->_debug("C: Add [dn: $dn]: ".print_r($newentry, true)); 465 440 466 $res = ldap_add($this->conn, $dn, $newentry); 441 467 if ($res === FALSE) { 468 $this->_debug("S: ".ldap_error($this->conn)); 442 469 return false; 443 470 } // end if 471 472 $this->_debug("S: OK"); 444 473 445 474 return base64_encode($dn); … … 493 522 if (!empty($deletedata)) { 494 523 // Delete the fields. 495 if (!ldap_mod_del($this->conn, $dn, $deletedata)) 524 $this->_debug("C: Delete [dn: $dn]: ".print_r($deletedata, true)); 525 if (!ldap_mod_del($this->conn, $dn, $deletedata)) { 526 $this->_debug("S: ".ldap_error($this->conn)); 496 527 return false; 528 } 529 $this->_debug("S: OK"); 497 530 } // end if 498 531 … … 508 541 // Replace the fields. 509 542 if (!empty($replacedata)) { 510 if (!ldap_mod_replace($this->conn, $dn, $replacedata)) 543 $this->_debug("C: Replace [dn: $dn]: ".print_r($replacedata, true)); 544 if (!ldap_mod_replace($this->conn, $dn, $replacedata)) { 545 $this->_debug("S: ".ldap_error($this->conn)); 511 546 return false; 547 } 548 $this->_debug("S: OK"); 512 549 } // end if 513 550 } // end if … … 515 552 if (!empty($newdata)) { 516 553 // Add the fields. 517 if (!ldap_mod_add($this->conn, $dn, $newdata)) 554 $this->_debug("C: Add [dn: $dn]: ".print_r($newdata, true)); 555 if (!ldap_mod_add($this->conn, $dn, $newdata)) { 556 $this->_debug("S: ".ldap_error($this->conn)); 518 557 return false; 558 } 559 $this->_debug("S: OK"); 519 560 } // end if 520 561 521 562 // Handle RDN change 522 563 if (!empty($newrdn)) { 523 if (@ldap_rename($this->conn, $dn, $newrdn, NULL, TRUE)) 564 $this->_debug("C: Rename [dn: $dn] [dn: $newrdn]"); 565 if (@ldap_rename($this->conn, $dn, $newrdn, NULL, TRUE)) { 566 $this->_debug("S: ".ldap_error($this->conn)); 524 567 return base64_encode($newdn); 568 } 569 $this->_debug("S: OK"); 525 570 } 526 571 … … 544 589 foreach ($dns as $id) { 545 590 $dn = base64_decode($id); 591 $this->_debug("C: Delete [dn: $dn]"); 546 592 // Delete the record. 547 593 $res = ldap_delete($this->conn, $dn); 548 594 if ($res === FALSE) { 595 $this->_debug("S: ".ldap_error($this->conn)); 549 596 return false; 550 597 } // end if 598 $this->_debug("S: OK"); 551 599 } // end foreach 552 600 … … 567 615 $function = $this->prop['scope'] == 'sub' ? 'ldap_search' : ($this->prop['scope'] == 'base' ? 'ldap_read' : 'ldap_list'); 568 616 569 if ($this->ldap_result = @$function($this->conn, $this->prop['base_dn'], $filter, array_values($this->fieldmap), 0, 0)) 617 $this->_debug("C: Search [".$filter."]"); 618 619 if ($this->ldap_result = @$function($this->conn, $this->prop['base_dn'], $filter, array_values($this->fieldmap), 0, 0)) { 620 $this->_debug("S: ".ldap_count_entries($this->conn, $this->ldap_result)." record(s)"); 570 621 return true; 622 } else 623 $this->_debug("S: ".ldap_error($this->conn)); 571 624 } 572 625 … … 590 643 { 591 644 if ($rec[$lf]['count']) { 592 if ($rf == 'email' && !strpos($rec[$lf][0], '@'))593 $out[$rf] = sprintf('%s@%s', $rec[$lf][0] , $RCMAIL->config->mail_domain($_SESSION['imap_host']));645 if ($rf == 'email' && $mail_domain && !strpos($rec[$lf][0], '@')) 646 $out[$rf] = sprintf('%s@%s', $rec[$lf][0], $this->mail_domain); 594 647 else 595 648 $out[$rf] = $rec[$lf][0]; … … 628 681 629 682 /** 683 * @access private 684 */ 685 private function _debug($str) 686 { 687 if ($this->debug) 688 write_log('ldap', $str); 689 } 690 691 692 /** 630 693 * @static 631 694 */
Note: See TracChangeset
for help on using the changeset viewer.
