Overview

Packages

  • None
  • Passwd

Classes

  • Passwd
  • Passwd_Driver
  • Passwd_Driver_Adsi
  • Passwd_Driver_Composite
  • Passwd_Driver_Expect
  • Passwd_Driver_Expectpecl
  • Passwd_Driver_Horde
  • Passwd_Driver_Http
  • Passwd_Driver_Kolab
  • Passwd_Driver_Ldap
  • Passwd_Driver_Pine
  • Passwd_Driver_Poppassd
  • Passwd_Driver_Procopen
  • Passwd_Driver_Pspasswd
  • Passwd_Driver_Servuftp
  • Passwd_Driver_Smbldap
  • Passwd_Driver_Smbpasswd
  • Passwd_Driver_Soap
  • Passwd_Driver_Sql
  • Passwd_Driver_Vmailmgr
  • Passwd_Driver_Vpopmail
  • Passwd_Exception
  • Passwd_Factory_Driver
  • Overview
  • Package
  • Class
  • Tree
 1: <?php
 2: /**
 3:  * The Horde driver attempts to change a user's password without
 4:  * caring about the actual implementation.
 5:  *
 6:  * It relies on the current horde authentication mechanism's ability to update
 7:  * the user.
 8:  *
 9:  * Copyright 2011-2012 Horde LLC (http://www.horde.org/)
10:  *
11:  * See the enclosed file COPYING for license information (GPL). If you
12:  * did not receive this file, see http://www.horde.org/licenses/gpl.php.
13:  *
14:  * @author  Ralf Lang <lang@b1-systems.de>
15:  * @package Passwd
16:  */
17: class Passwd_Driver_Horde extends Passwd_Driver
18: {
19:     /**
20:      * Changes the user's password.
21:      *
22:      * @param string $username      The user for which to change the password.
23:      * @param string $old_password  The old (current) user password.
24:      * @param string $new_password  The new user password to set.
25:      *
26:      * @throws Passwd_Exception
27:      */
28:     public function changePassword($username, $old_password, $new_password)
29:     {
30:         if (!$this->_params['auth']->hasCapability('update')) {
31:             throw new Passwd_Exception(_("The current horde configuration does not allow changing passwords."));
32:         }
33: 
34:         /* Check the provided old password. */
35:         try {
36:             if ($this->_params['auth']->authenticate($username, array('password' => $old_password, false))) {
37:                 /* Actually modify the password. */
38:                 $this->_params['auth']->updateUser($username, $username, array('password' => $new_password));
39:             } else {
40:                 throw new Passwd_Exception(_("Incorrect old password."));
41:             }
42:         } catch (Horde_Auth_Exception $e) {
43:             throw new Passwd_Exception($e);
44:         }
45:     }
46: }
47: 
API documentation generated by ApiGen