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 SOAP driver attempts to change a user's password through a SOAP
 4:  * request.
 5:  *
 6:  * Copyright 2009-2012 Horde LLC (http://www.horde.org/)
 7:  *
 8:  * See the enclosed file COPYING for license information (GPL). If you
 9:  * did not receive this file, see http://www.horde.org/licenses/gpl.php.
10:  *
11:  * @author  Jan Schneider <jan@horde.org>
12:  * @package Passwd
13:  */
14: class Passwd_Driver_Soap extends Passwd_Driver
15: {
16:     /**
17:      * Constructor.
18:      *
19:      * @param array $params  A hash containing connection parameters.
20:      *
21:      * @throws Passwd_Exception
22:      */
23:     public function __construct($params = array())
24:     {
25:         if (!class_exists('SoapClient')) {
26:             throw new Passwd_Exception('You need the soap PHP extension to use this driver.');
27:         }
28: 
29:         if (empty($params['wsdl']) &&
30:             (empty($params['soap_params']['location']) ||
31:              empty($params['soap_params']['uri']))) {
32:             throw new Passwd_Exception('Either the "wsdl" or the "location" and "uri" parameter must be provided.');
33:         }
34: 
35:         if (isset($params['wsdl'])) {
36:             unset($params['soap_params']['location']);
37:             unset($params['soap_params']['uri']);
38:         }
39:         $params['soap_params']['exceptions'] = false;
40: 
41:         parent::__construct($params);
42:     }
43: 
44:     /**
45:      * Changes the user's password.
46:      *
47:      * @param string $username      The user for which to change the password.
48:      * @param string $old_password  The old (current) user password.
49:      * @param string $new_password  The new user password to set.
50:      *
51:      * @throws Passwd_Exception
52:      */
53:     public function changePassword($username, $old_password, $new_password)
54:     {
55:         $args = array();
56:         if (($pos = array_search('username', $this->_params['arguments'])) !== false) {
57:             $args[$pos] = $username;
58:         }
59:         if (($pos = array_search('oldpassword', $this->_params['arguments'])) !== false) {
60:             $args[$pos] = $old_password;
61:         }
62:         if (($pos = array_search('newpassword', $this->_params['arguments'])) !== false) {
63:             $args[$pos] = $new_password;
64:         }
65: 
66:         $client = new SoapClient($this->_params['wsdl'],
67:                                  $this->_params['soap_params']);
68:         $result = $client->__soapCall($this->_params['method'], $args);
69:         if ($result instanceof SoapFault) {
70:             throw new Passwd_Exception($result->getMessage(), $result->getCode());
71:         }
72:     }
73: }
74: 
API documentation generated by ApiGen