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