function ispcfg3_ChangePassword($params) { $username = $params['username']; $password = $params['password']; $clientsdetails = $params['clientsdetails']; $soapuser = $params['configoption1']; $soappassword = $params['configoption2']; $soapsvrurl = $params['configoption3']; $soapsvrssl = $params['configoption4']; if ($soapsvrssl == 'on') { $soap_url = 'https://' . $soapsvrurl . '/remote/index.php'; $soap_uri = 'https://' . $soapsvrurl . '/remote/'; } else { $soap_url = 'http://' . $soapsvrurl . '/remote/index.php'; $soap_uri = 'http://' . $soapsvrurl . '/remote/'; } if (isset($username) && $username != '' && (isset($password) && $password != '')) { try { /* Connect to SOAP Server */ $client = new SoapClient(null, array('location' => $soap_url, 'uri' => $soap_uri, 'exceptions' => 1, 'trace' => false)); /* Authenticate with the SOAP Server */ $session_id = $client->login($soapuser, $soappassword); $domain_id = $client->client_get_by_username($session_id, $username); $client_id = $domain_id['client_id']; $returnresult = $client->client_change_password($session_id, $client_id, $password); logModuleCall('ispconfig', 'ChangePassword', $clientsdetails, $returnresult, '', ''); if ($client->logout($session_id)) { } if ($returnresult == 1) { $successful = '1'; } else { $successful = '0'; $result = "Password change failed"; } } catch (SoapFault $e) { $error = 'SOAP Error: ' . $e->getMessage(); $successful = '0'; } if ($successful == 1) { $result = 'success'; } else { $result = 'Error: ' . $error; } } else { /* * No username or password set. */ $result = 'Username or Password is Blank or Not Set'; } return $result; }
<?php require 'soap_config.php'; $client = new SoapClient(null, array('location' => $soap_location, 'uri' => $soap_uri, 'trace' => 1, 'exceptions' => 1)); try { if ($session_id = $client->login($username, $password)) { echo 'Logged successfull. Session ID:' . $session_id . '<br />'; } //* Set the function parameters. $username = '******'; $record_record = $client->client_get_by_username($session_id, $username); print_r($record_record); if ($client->logout($session_id)) { echo 'Logged out.<br />'; } } catch (SoapFault $e) { echo $client->__getLastResponse(); die('SOAP Error: ' . $e->getMessage()); }
public function Update($operate_array, $create_array, $client_options_array) { $soap_location = "http://" . $operate_array['ip'] . ":" . $operate_array['port'] . "/remote/index.php"; $soap_uri = "http://" . $operate_array['ip'] . ":" . $operate_array['port'] . "/remote/"; $username = $operate_array['adminname']; $password = $operate_array['adminpassword']; $client = new SoapClient(null, array('location' => $soap_location, 'uri' => $soap_uri)); if ($session_id = $client->login($username, $password)) { if ($clientid = $client->client_get_by_username($session_id, $create_array['clientlogin'])) { if ($client->client_update($session_id, $clientid, false, $client_options_array)) { return true; } else { throw new Exception("Unable to update user with ID: " . $clientid); } } else { throw new Exception("Unable to find client ID by username: "******"Unable to login into ISPConfig 3 with username " . $username . " and password *********"); } }