1: <?php
2: /**
3: * The driver for accessing objects stored in a filtered LDAP.
4: *
5: * PHP version 5
6: *
7: * @category Kolab
8: * @package Kolab_Server
9: * @author Gunnar Wrobel <wrobel@pardus.de>
10: * @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
11: * @link http://pear.horde.org/index.php?package=Kolab_Server
12: */
13:
14: /**
15: * This class provides methods to deal with objects stored in
16: * a filtered LDAP db.
17: *
18: * Copyright 2008-2012 Horde LLC (http://www.horde.org/)
19: *
20: * See the enclosed file COPYING for license information (LGPL). If you
21: * did not receive this file, see http://www.horde.org/licenses/lgpl21.
22: *
23: * @category Kolab
24: * @package Kolab_Server
25: * @author Gunnar Wrobel <wrobel@pardus.de>
26: * @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
27: * @link http://pear.horde.org/index.php?package=Kolab_Server
28: */
29: class Horde_Kolab_Server_Ldap_Filtered extends Horde_Kolab_Server_Ldap
30: {
31: /**
32: * A global filter to add to each query.
33: *
34: * @var string
35: */
36: private $_filter;
37:
38: /**
39: * Constructor.
40: *
41: * @param Horde_Kolab_Server_Connection $connection The LDAP connection.
42: * @param string $base_dn The LDAP server base DN.
43: * @param string $filter A global filter to add
44: * to all queries.
45: */
46: public function __construct(
47: Horde_Kolab_Server_Connection_Interface $connection,
48: $base_dn,
49: $filter = null
50: ) {
51: parent::__construct($connection, $base_dn);
52: $this->_filter = $filter;
53: }
54:
55: /**
56: * Finds all object data below a parent matching a given set of criteria.
57: *
58: * @param string $query The LDAP search query
59: * @param string $parent The parent to search below.
60: * @param array $params Additional search parameters.
61: *
62: * @return Horde_Kolab_Server_Result The result object.
63: *
64: * @throws Horde_Kolab_Server_Exception
65: */
66: public function findBelow($query, $parent, array $params = array())
67: {
68: $query = '(&(' . $this->_filter . ')' . $query . ')';
69: return $this->_search($query, $params, $parent);
70: }
71: }
72: