Changeset 2888 in subversion


Ignore:
Timestamp:
Aug 29, 2009 1:10:53 PM (4 years ago)
Author:
alec
Message:
  • Fix LDAP attributes case senitivity problems (#1485830)
Location:
trunk/roundcubemail
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/roundcubemail/CHANGELOG

    r2887 r2888  
    22=========================== 
    33 
     4- Fix LDAP attributes case senitivity problems (#1485830) 
    45- Fix LDAP addressbook browsing when only one directory is used (#1486022) 
    56- Fix endless loop on error response for APPEND command (#1486060) 
  • trunk/roundcubemail/program/include/rcube_ldap.php

    r2887 r2888  
    5656    foreach ($p as $prop => $value) 
    5757      if (preg_match('/^(.+)_field$/', $prop, $matches)) 
    58         $this->fieldmap[$matches[1]] = $value; 
    59  
    60     $this->sort_col = $p["sort"]; 
     58        $this->fieldmap[$matches[1]] = strtolower($value); 
     59 
     60    $this->sort_col = $p['sort']; 
    6161 
    6262    $this->connect(); 
     
    103103 
    104104      // User specific access, generate the proper values to use. 
    105       if ($this->prop["user_specific"]) { 
     105      if ($this->prop['user_specific']) { 
    106106        // No password set, use the session password 
    107107        if (empty($this->prop['bind_pass'])) { 
     
    167167    if ($this->conn) 
    168168    { 
    169       @ldap_unbind($this->conn); 
     169      ldap_unbind($this->conn); 
    170170      $this->conn = null; 
    171171    } 
     
    252252    // count contacts for this user 
    253253    $this->result = $this->count(); 
    254      
     254 
    255255    // we have a search result resource 
    256256    if ($this->ldap_result && $this->result->count > 0) 
    257257    { 
    258       if ($this->sort_col && $this->prop['scope'] !== "base") 
    259         @ldap_sort($this->conn, $this->ldap_result, $this->sort_col); 
     258      if ($this->sort_col && $this->prop['scope'] !== 'base') 
     259        ldap_sort($this->conn, $this->ldap_result, $this->sort_col); 
    260260 
    261261      $start_row = $subset < 0 ? $this->result->first + $this->page_size + $subset : $this->result->first; 
     
    382382    if ($this->conn && $dn) 
    383383    { 
    384       $this->ldap_result = @ldap_read($this->conn, base64_decode($dn), "(objectclass=*)", array_values($this->fieldmap)); 
     384      $this->ldap_result = ldap_read($this->conn, base64_decode($dn), "(objectclass=*)", array_values($this->fieldmap)); 
    385385      $entry = @ldap_first_entry($this->conn, $this->ldap_result); 
    386        
     386 
    387387      if ($entry && ($rec = ldap_get_attributes($this->conn, $entry))) 
    388388      { 
     389        $rec = array_change_key_case($rec, CASE_LOWER); 
     390 
    389391        // Add in the dn for the entry. 
    390         $rec["dn"] = base64_decode($dn); 
     392        $rec['dn'] = base64_decode($dn); 
    391393        $res = $this->_ldap2result($rec); 
    392394        $this->result = new rcube_result_set(1); 
     
    409411    // Map out the column names to their LDAP ones to build the new entry. 
    410412    $newentry = array(); 
    411     $newentry["objectClass"] = $this->prop["LDAP_Object_Classes"]; 
     413    $newentry['objectClass'] = $this->prop['LDAP_Object_Classes']; 
    412414    foreach ($save_cols as $col => $val) { 
    413       $fld = ""; 
    414415      $fld = $this->_map_field($col); 
    415       if ($fld != "") { 
     416      if ($fld != '') { 
    416417        // The field does exist, add it to the entry. 
    417418        $newentry[$fld] = $val; 
     
    422423    // We know that the email address is required as a default of rcube, so 
    423424    // we will default its value into any unfilled required fields. 
    424     foreach ($this->prop["required_fields"] as $fld) { 
     425    foreach ($this->prop['required_fields'] as $fld) { 
    425426      if (!isset($newentry[$fld])) { 
    426         $newentry[$fld] = $newentry[$this->_map_field("email")]; 
     427        $newentry[$fld] = $newentry[$this->_map_field('email')]; 
    427428      } // end if 
    428429    } // end foreach 
    429430 
    430431    // Build the new entries DN. 
    431     $dn = $this->prop["LDAP_rdn"]."=".$newentry[$this->prop["LDAP_rdn"]].",".$this->prop['base_dn']; 
    432     $res = @ldap_add($this->conn, $dn, $newentry); 
     432    $dn = $this->prop['LDAP_rdn'].'='.$newentry[$this->prop['LDAP_rdn']].','.$this->prop['base_dn']; 
     433    $res = ldap_add($this->conn, $dn, $newentry); 
    433434    if ($res === FALSE) { 
    434435      return false; 
     
    456457    $deletedata = array(); 
    457458    foreach ($save_cols as $col => $val) { 
    458       $fld = ""; 
    459459      $fld = $this->_map_field($col); 
    460       if ($fld != "") { 
     460      if ($fld != '') { 
    461461        // The field does exist compare it to the ldap record. 
    462462        if ($record[$col] != $val) { 
     
    466466            $newdata[$fld] = $val; 
    467467          } // end if 
    468           elseif ($val == "") { 
     468          elseif ($val == '') { 
    469469            // Field supplied is empty, verify that it is not required. 
    470             if (!in_array($fld, $this->prop["required_fields"])) { 
     470            if (!in_array($fld, $this->prop['required_fields'])) { 
    471471              // It is not, safe to clear. 
    472472              $deletedata[$fld] = $record[$col]; 
     
    485485    if (!empty($deletedata)) { 
    486486      // Delete the fields. 
    487       $res = @ldap_mod_del($this->conn, $dn, $deletedata); 
     487      $res = ldap_mod_del($this->conn, $dn, $deletedata); 
    488488      if ($res === FALSE) { 
    489489        return false; 
     
    493493    if (!empty($replacedata)) { 
    494494      // Replace the fields. 
    495       $res = @ldap_mod_replace($this->conn, $dn, $replacedata); 
     495      $res = ldap_mod_replace($this->conn, $dn, $replacedata); 
    496496      if ($res === FALSE) { 
    497497        return false; 
     
    501501    if (!empty($newdata)) { 
    502502      // Add the fields. 
    503       $res = @ldap_mod_add($this->conn, $dn, $newdata); 
     503      $res = ldap_mod_add($this->conn, $dn, $newdata); 
    504504      if ($res === FALSE) { 
    505505        return false; 
     
    521521    if (!is_array($ids)) { 
    522522      // Not an array, break apart the encoded DNs. 
    523       $dns = explode(",", $ids); 
     523      $dns = explode(',', $ids); 
    524524    } // end if 
    525525 
     
    527527      $dn = base64_decode($id); 
    528528      // Delete the record. 
    529       $res = @ldap_delete($this->conn, $dn); 
     529      $res = ldap_delete($this->conn, $dn); 
    530530      if ($res === FALSE) { 
    531531        return false; 
     
    592592  } 
    593593 
    594  
    595594} 
    596595 
    597  
     596?> 
Note: See TracChangeset for help on using the changeset viewer.