Changeset e3caaf5 in github


Ignore:
Timestamp:
May 17, 2007 11:58:51 AM (6 years ago)
Author:
thomascube <thomas@…>
Branches:
master, HEAD, courier-fix, dev-browser-capabilities, pdo, release-0.6, release-0.7, release-0.8
Children:
7198044
Parents:
02342ff
Message:

Use global filters and bind username/ for Ldap searches (#1484159)

Files:
3 edited

Legend:

Unmodified
Added
Removed
  • CHANGELOG

    r0289535 re3caaf5  
    442007/05/17 (thomasb) 
    55---------- 
    6 - Updated Catalan, Russian, and Chinese translations 
     6- Updated Catalan, Russian, Portuguese and Chinese translations 
    77- Renamed localization folder for Chinese (Big5) 
    88- Chanegd Slovenian language code from 'si' to 'sl' 
     9- Added Sinhala (Sri-Lanka) localization 
     10- Use global filters and bind username/ for Ldap searches (#1484159) 
    911 
    1012 
  • config/main.inc.php.dist

    rf115416 re3caaf5  
    198198 *  'port'          => 389, 
    199199 *  'base_dn'       => '', 
     200 *  'bind_dn'       => '', 
     201 *  'bind_pass'     => '', 
    200202 *  'search_fields' => array('mail', 'cn'),  // fields to search in 
    201203 *  'name_field'    => 'cn',    // this field represents the contact's name 
    202204 *  'email_field'   => 'mail',  // this field represents the contact's e-mail 
    203205 *  'scope'         => 'sub',   // search mode: sub|base|list 
     206 *  'filter'        => '',      // will be &'d with search field ex: (status=act) 
    204207 *  'fuzzy_search'  => true);   // server allows wildcard search 
    205208 */ 
  • program/include/rcube_ldap.inc

    rf115416 re3caaf5  
    9494     
    9595    if (is_resource($this->conn)) 
     96    { 
    9697      $this->ready = true; 
     98      if (!empty($this->prop['bind_dn']) && !empty($this->prop['bind_pass'])) 
     99        $this->ready = $this->bind($this->prop['bind_dn'], $this->prop['bind_pass']); 
     100    } 
    97101    else 
    98102      raise_error(array('type' => 'ldap', 'message' => "Could not connect to any LDAP server, tried $host:{$this->prop[port]} last"), true); 
     
    101105 
    102106  /** 
    103    * Merge with connect()? 
    104    */ 
    105   function bind($dn=null, $pass=null) 
    106   { 
    107     if ($this->conn) 
    108     { 
    109       if ($dn) 
    110       { 
    111         if (@ldap_bind($this->conn, $dn, $pass)) 
    112           return true; 
    113         else 
    114           raise_error(array('code' => ldap_errno($this->conn), 
    115                             'type' => 'ldap', 
    116                             'message' => "Bind failed for dn=$dn: ".ldap_error($this->conn)), 
    117                       true); 
    118       } 
    119       else 
    120       { 
    121         if (@ldap_bind($this->conn)) 
    122           return true; 
    123         else 
    124           raise_error(array('code' => ldap_errno($this->conn), 
    125                             'type' => 'ldap', 
    126                             'message' => "Anonymous bind failed: ".ldap_error($this->conn)), 
    127                       true); 
    128         } 
    129     } 
     107   * Bind connection with DN and password 
     108   */ 
     109  function bind($dn, $pass) 
     110  { 
     111    if (!$this->conn) 
     112      return false; 
     113     
     114    if (@ldap_bind($this->conn, $dn, $pass)) 
     115      return true; 
    130116    else 
    131       raise_error(array('type' => 'ldap', 'message' => "Attempted bind on nonexistent connection"), true); 
    132        
     117    { 
     118      raise_error(array( 
     119        'code' => ldap_errno($this->conn), 
     120        'type' => 'ldap', 
     121        'message' => "Bind failed for dn=$dn: ".ldap_error($this->conn)), 
     122      true); 
     123    } 
     124     
    133125    return false; 
    134     } 
     126  } 
    135127 
    136128 
     
    271263    } 
    272264    $filter .= ')'; 
     265     
     266    // add general filter to query 
     267    if (!empty($this->prop['filter'])) 
     268      $filter = '(&'.$this->prop['filter'] . $filter . ')'; 
    273269 
    274270    // set filter string and execute search 
     
    386382    { 
    387383      $function = $this->prop['scope'] == 'sub' ? 'ldap_search' : ($this->prop['scope'] == 'base' ? 'ldap_read' : 'ldap_list'); 
    388       $this->ldap_result = @$function($this->conn, $this->prop['base_dn'], $this->filter, array_values($this->fieldmap), 0, 0); 
     384      $this->ldap_result = $function($this->conn, $this->prop['base_dn'], $this->filter, array_values($this->fieldmap), 0, 0); 
    389385      return true; 
    390386    } 
Note: See TracChangeset for help on using the changeset viewer.