1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13:
14: class Passwd_Driver_Soap extends Passwd_Driver
15: {
16: 17: 18: 19: 20: 21: 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: 46: 47: 48: 49: 50: 51: 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: