1: <?php
2: /**
3: * This class provides a Kolab driver for the Horde group system.
4: *
5: * Copyright 2005-2012 Horde LLC (http://www.horde.org/)
6: *
7: * See the enclosed file COPYING for license information (LGPL). If you
8: * did not receive this file, see http://www.horde.org/licenses/lgpl21.
9: *
10: * @author Gunnar Wrobel <wrobel@pardus.de>
11: * @author Jan Schneider <jan@horde.org>
12: * @category Horde
13: * @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
14: * @package Group
15: */
16: class Horde_Group_Kolab extends Horde_Group_Ldap
17: {
18: /**
19: * Constructor.
20: *
21: * @throws Horde_Group_Exception
22: */
23: /*
24: public function __construct($params)
25: {
26: $this->_params = array(
27: 'hostspec' => $GLOBALS['conf']['kolab']['ldap']['server'],
28: 'basedn' => $GLOBALS['conf']['kolab']['ldap']['basedn'],
29: 'binddn' => $GLOBALS['conf']['kolab']['ldap']['phpdn'],
30: 'password' => $GLOBALS['conf']['kolab']['ldap']['phppw'],
31: 'version' => 3,
32: 'gid' => 'cn',
33: 'memberuid' => 'member',
34: 'attrisdn' => true,
35: 'filter_type' => 'objectclass',
36: 'objectclass' => 'kolabGroupOfNames',
37: 'newgroup_objectclass' => 'kolabGroupOfNames'
38: );
39:
40: $this->_filter = 'objectclass=' . $this->_params['objectclass'];
41: }
42: */
43:
44: /**
45: * Returns a list of groups a user belongs to.
46: *
47: * @param string $user A user name.
48: *
49: * @return array A list of groups, with IDs as keys and names as values.
50: * @throws Horde_Group_Exception
51: */
52: public function listGroups($user)
53: {
54: return parent::listGroups($this->_dnForMail($user));
55: }
56:
57: /**
58: * Tries to find a DN for a given kolab mail address.
59: *
60: * @param string $mail The mail address to search for.
61: *
62: * @return string The corresponding dn or false.
63: * @throws Horde_Group_Exception
64: */
65: protected function _dnForMail($mail)
66: {
67: try {
68: $filter = Horde_Ldap_Filter::combine(
69: 'and',
70: array(Horde_Ldap_Filter::create('objectclass', 'equals', 'kolabInetOrgPerson'),
71: Horde_Ldap_Filter::create('mail', 'equals', $mail)));
72: $search = $this->_ldap->search($this->_params['basedn'], $filter, array('dn'));
73: if ($search->count()) {
74: return $search->shiftEntry()->dn();
75: }
76: } catch (Horde_Ldap_Exception $e) {
77: throw new Horde_Group_Exception($e);
78: }
79:
80: throw new Horde_Group_Exception(sprintf('Error searching for user with the email address "%s"', $mail));
81: }
82: }
83: