1<?php
2/**
3 * The Horde_Core_Auth_Ldap class provides Horde-specific code that
4 * extends the base LDAP driver.
5 *
6 * Copyright 2010-2017 Horde LLC (http://www.horde.org/)
7 *
8 * See the enclosed file COPYING for license information (LGPL). If you did
9 * not receive this file, see http://opensource.org/licenses/lgpl-2.1.php
10 *
11 * @author   Michael Slusarz <slusarz@horde.org>
12 * @category Horde
13 * @license  http://opensource.org/licenses/lgpl-2.1.php LGPL
14 * @package  Core
15 */
16class Horde_Core_Auth_Ldap extends Horde_Auth_Ldap
17{
18    /**
19     * Add a set of authentication credentials.
20     *
21     * @param string $userId      The user ID to add.
22     * @param array $credentials  The credentials to use.
23     *
24     * @throws Horde_Auth_Exception
25     */
26    public function addUser($userId, $credentials)
27    {
28        list($userId, $credentials) = $GLOBALS['injector']->getInstance('Horde_Core_Factory_Auth')->create()->runHook($userId, $credentials, 'preauthenticate', 'admin');
29
30        parent::addUser($userId, $credentials);
31    }
32
33    /**
34     * Update a set of authentication credentials.
35     *
36     * @param string $oldID       The old user ID.
37     * @param string $newID       The new user ID.
38     * @param array $credentials  The new credentials
39     * @param string $olddn       NOT USED.
40     * @param string $newdn       NOT USED.
41     *
42     * @throws Horde_Auth_Exception
43     */
44    public function updateUser($oldID, $newID, $credentials, $olddn = null,
45                               $newdn = null)
46    {
47        $auth = $GLOBALS['injector']->getInstance('Horde_Core_Factory_Auth')->create();
48
49        list($oldID, $old_credentials) = $auth->runHook($oldID, $credentials, 'preauthenticate', 'admin');
50        list($newID, $new_credentials) = $auth->runHook($newID, $credentials, 'preauthenticate', 'admin');
51        $olddn = isset($old_credentials['dn']) ? $old_credentials['dn'] : null;
52        $newdn = isset($new_credentials['dn']) ? $new_credentials['dn'] : null;
53
54        parent::updateUser($oldID, $newID, $new_credentials, $olddn, $newdn);
55    }
56
57    /**
58     * Delete a set of authentication credentials.
59     *
60     * @param string $userId  The user ID to delete.
61     * @param string $dn      NOT USED.
62     *
63     * @throws Horde_Auth_Exception
64     */
65    public function removeUser($userId, $dn = null)
66    {
67        list($userId, $credentials) = $GLOBALS['injector']->getInstance('Horde_Core_Factory_Auth')->create()->runHook($userId, array(), 'preauthenticate', 'admin');
68
69        parent::removeUser($userId, isset($credentials['ldap']) ? $credentials['ldap']['dn'] : null);
70    }
71
72}
73