Changeset d1e08fc in github


Ignore:
Timestamp:
Apr 15, 2011 11:55:38 AM (2 years ago)
Author:
thomascube <thomas@…>
Branches:
master, HEAD, courier-fix, dev-browser-capabilities, pdo, release-0.6, release-0.7, release-0.8
Children:
ef27a6a
Parents:
1f6ab35
Message:

Replace LDAP vars in group queries (#1487837)

Files:
3 edited

Legend:

Unmodified
Added
Removed
  • CHANGELOG

    rbf80b5a rd1e08fc  
    22=========================== 
    33 
     4- Replace LDAP vars in group queries (#1487837) 
    45- Fix vcard folding with uncode characters (#1487868) 
    56- Keep all submitted data if contact form validation fails (#1487865) 
  • config/main.inc.php.dist

    rae39c47 rd1e08fc  
    513513  'sort'          => 'cn',    // The field to sort the listing by. 
    514514  'scope'         => 'sub',   // search mode: sub|base|list 
    515   'filter'        => '',      // used for basic listing (if not empty) and will be &'d with search queries. example: status=act 
     515  'filter'        => '(objectClass=inetOrgPerson)',      // used for basic listing (if not empty) and will be &'d with search queries. example: status=act 
    516516  'fuzzy_search'  => true,    // server allows wildcard search 
    517517  'sizelimit'     => '0',     // Enables you to limit the count of entries fetched. Setting this to 0 means no limit. 
    518518  'timelimit'     => '0',     // Sets the number of seconds how long is spend on the search. Setting this to 0 means no limit. 
    519   // definition for groups, set to false if no groups are supported 
     519 
     520  // definition for contact groups (uncomment if no groups are supported) 
     521  // for the groups base_dn, the user replacements %fu, %u, $d and %dc work as for base_dn (see above) 
     522  // if the groups base_dn is empty, the contact base_dn is used for the groups as well 
     523  // -> in thist case, assure that groups and contacts are seperated due to the concernig filters!  
    520524  'groups'        => array( 
    521     'base_dn'     => 'ou=groups,ou=rcabook,dc=localhost', 
     525    'base_dn'     => '',    
    522526    'filter'      => '(objectClass=groupOfNames)', 
     527    'object_classes' => array("top", "groupOfNames"), 
    523528  ), 
    524529); 
  • program/include/rcube_ldap.php

    r15e9441 rd1e08fc  
    5050    protected $debug = false; 
    5151 
     52    private $base_dn = ''; 
     53    private $groups_base_dn = ''; 
    5254    private $group_cache = array(); 
    5355    private $group_members = array(); 
     
    6769 
    6870        // check if groups are configured 
    69         if (is_array($p['groups'])) 
     71        if (is_array($p['groups']) and count($p['groups'])) 
    7072            $this->groups = true; 
    7173 
     
    203205                // Replace the bind_dn and base_dn variables. 
    204206                $bind_dn   = strtr($bind_dn, $replaces); 
    205                 $base_dn   = strtr($base_dn, $replaces); 
     207                $this->base_dn   = strtr($base_dn, $replaces); 
    206208 
    207209                if (empty($bind_user)) { 
     
    645647 
    646648        // Build the new entries DN. 
    647         $dn = $this->prop['LDAP_rdn'].'='.$this->_quote_string($newentry[$this->prop['LDAP_rdn']], true).','.$this->prop['base_dn']; 
     649        $dn = $this->prop['LDAP_rdn'].'='.$this->_quote_string($newentry[$this->prop['LDAP_rdn']], true).','.$this->base_dn; 
    648650 
    649651        $this->_debug("C: Add [dn: $dn]: ".print_r($newentry, true)); 
     
    729731                $newdn = $this->prop['LDAP_rdn'].'=' 
    730732                    .$this->_quote_string($replacedata[$this->prop['LDAP_rdn']], true) 
    731                     .','.$this->prop['base_dn']; 
     733                    .','.$this->base_dn; 
    732734                if ($dn != $newdn) { 
    733735                    $newrdn = $this->prop['LDAP_rdn'].'=' 
     
    838840            $this->_debug("C: Search [".$filter."]"); 
    839841 
    840             if ($this->ldap_result = @$function($this->conn, $this->prop['base_dn'], $filter, 
     842            if ($this->ldap_result = @$function($this->conn, $this->base_dn, $filter, 
    841843                array_values($this->fieldmap), 0, (int) $this->prop['sizelimit'], (int) $this->prop['timelimit'])) 
    842844            { 
     
    973975    function list_groups($search = null) 
    974976    { 
     977        global $RCMAIL; 
     978 
    975979        if (!$this->groups) 
    976980            return array(); 
    977981 
    978         $base_dn = $this->prop['groups']['base_dn']; 
    979         $filter = '(objectClass=groupOfNames)'; 
     982        $this->groups_base_dn = ($this->prop['groups']['base_dn']) ? 
     983                $this->prop['groups']['base_dn'] : $this->base_dn; 
     984 
     985        // replace user specific dn 
     986        if ($this->prop['user_specific']) 
     987        { 
     988            $fu = $RCMAIL->user->get_username(); 
     989            list($u, $d) = explode('@', $fu); 
     990            $dc = 'dc='.strtr($d, array('.' => ',dc=')); 
     991            $replaces = array('%dc' => $dc, '%d' => $d, '%fu' => $fu, '%u' => $u); 
     992 
     993            $this->groups_base_dn = strtr($this->groups_base_dn, $replaces);; 
     994        } 
     995 
     996        $base_dn = $this->groups_base_dn; 
     997        $filter = $this->prop['groups']['filter']; 
    980998 
    981999        $res = ldap_search($this->conn, $base_dn, $filter, array('cn','member')); 
     
    10161034            $this->list_groups(); 
    10171035 
    1018         $base_dn = $this->prop['groups']['base_dn']; 
     1036        $base_dn = $this->groups_base_dn; 
    10191037        $new_dn = "cn=$group_name,$base_dn"; 
    10201038        $new_gid = base64_encode($group_name); 
    10211039 
    10221040        $new_entry = array( 
    1023             'objectClass' => array('top', 'groupOfNames'), 
     1041            'objectClass' => $this->prop['groups']['object_classes'], 
    10241042            'cn' => $group_name, 
    10251043            'member' => '', 
     
    10471065            $this->list_groups(); 
    10481066 
    1049         $base_dn = $this->prop['groups']['base_dn']; 
     1067        $base_dn = $this->groups_base_dn; 
    10501068        $group_name = $this->group_cache[$group_id]['name']; 
    10511069 
     
    10741092            $this->list_groups(); 
    10751093 
    1076         $base_dn = $this->prop['groups']['base_dn']; 
     1094        $base_dn = $this->groups_base_dn; 
    10771095        $group_name = $this->group_cache[$group_id]['name']; 
    10781096        $old_dn = "cn=$group_name,$base_dn"; 
     
    11021120            $this->list_groups(); 
    11031121 
    1104         $base_dn = $this->prop['groups']['base_dn']; 
     1122        $base_dn = $this->groups_base_dn; 
    11051123        $group_name = $this->group_cache[$group_id]['name']; 
    11061124        $group_dn = "cn=$group_name,$base_dn"; 
     
    11321150            $this->list_groups(); 
    11331151 
    1134         $base_dn = $this->prop['groups']['base_dn']; 
     1152        $base_dn = $this->groups_base_dn; 
    11351153        $group_name = $this->group_cache[$group_id]['name']; 
    11361154        $group_dn = "cn=$group_name,$base_dn"; 
     
    11631181            return array(); 
    11641182 
    1165         $base_dn = $this->prop['groups']['base_dn']; 
     1183        $base_dn = $this->groups_base_dn; 
    11661184        $contact_dn = base64_decode($contact_id); 
    11671185        $filter = "(member=$contact_dn)"; 
Note: See TracChangeset for help on using the changeset viewer.