Hi Community! I'm new at ISPConfig, and new at the api coding. I'm currently trying to build an overlay, to automate some stuff, and make it "prettier" However, I found a problem, that for me seems odd. But when i look through the api coding, it looks like there is no real way of finding a clients FTP accounts, without knowing the primary_id of said ftp user. Am i missing something, or? Edit: I just realized, i posted in the wrong forum. Sorry about that. Best Regards Kris.
The api allows you to query users for all fields that are available in the database by using the advanced syntax of the *_get functions. e.g.: http://www.howtoforge.com/forums/showthread.php?t=66220
Hi Till. Thanks for a quick response. I'm currently using this code, to spit out everything i can from the database about the user. PHP: <?php require 'soap_config.php'; $client = new SoapClient(null, array('location' => $soap_location, 'uri' => $soap_uri, 'trace' => 1, 'exceptions' => 1)); try { //* Login to the remote server if( $session_id = $client->login($username,$password)) { echo "Logged into remote server sucessfully. <br />\n"; echo "SessionID : ".$session_id."<br />\n"; $client_info = $client->client_get_by_username($session_id, $_POST['usr']); $client_info_ext = $client->client_get($session_id, $client_info['client_id']); $client_sites = $client->client_get_sites_by_user($session_id, $client_info['sys_userid'], $client_info['sys_groupid']); $client_ftp_get = $client->sites_ftp_user_get($session_id, $client_info['sys_groupid']); if($client->logout($session_id)) { echo "Logout Succesfully!<br />\n"; } else { echo "Logout Failed!<br />\n"; } echo "<br />\n"; //print_r($client_info); echo "<b>Sys user info :</b><br />\n"; foreach ($client_info as $key => $value) { echo $key . " = " . $value . "<br />\n"; } echo "<br />\n<br />\n"; echo "<b>Client user info :</b><br />\n"; foreach ($client_info_ext as $key => $value) { echo $key . " = " . $value . "<br />\n"; } echo "<br />\n<br />\n"; echo "<b>Client Sites :</b><br />\n"; foreach ($client_sites as $key => $results) { echo "Site $key : <br />\n"; foreach ($results as $key => $value) { echo $key . " = " . $value . "<br />\n"; } echo "<br />\n"; } echo "<b>Client FTP Users :</b><br />\n"; foreach ($client_ftp_get as $key => $value) { echo $key . " = " . $value . "<br />\n"; } echo "<br />\n<br />\n"; $salt = substr($client_info_ext['password'], 0, 11); echo "Salt: " . $salt . "<br />\n<br />\n"; $usr_pwd = $_POST['pwd']; //$combined_pwd = $salt . $usr_pwd; if(crypt($usr_pwd, $salt) == $client_info_ext['password']) { echo "Login Successfully!"; } else { echo "Login Failed!"; } //* Logout //if($client->logout($session_id)) { // echo "<br />\n<br />\n Logged out of Remote Server.<br />\n"; //} } } catch (SoapFault $e) { die('SOAP Error: '.$e->getMessage()); } ?> And as i stated, i can't find any reference from any info in the users table, to the number of ftp accounts. I'm not trying to find info on a specific ftp account, but to generate a list of ftp accounts. Sorry for the messy code, I'm still stuck on old-school php, since i havent touched php in several years. Best Regards Kris
The $client_info['sys_userid'] and $client_info['sys_groupid'] identifies the owner of the client (e.g. admin or reseller), so this id is not suitable if you want to find a record that is owned by the client. This way you will find only records that are owned by the owner of the client. 1) This 2 functions can be combined: $client_info = $client->client_get_by_username($session_id, $_POST['usr']); $client_info_ext = $client->client_get($session_id, $client_info['client_id']); to $client_info = $client->client_get($session_id, array('username' => $_POST['usr'])); To get items of any kind by its owner, then you need to know his groupid: $client_groupid = $client->client_get_groupid($session_id, $client_info['client_id']); to get all FTP users that are owned by this client, use: $client_ftp_get = $client->sites_ftp_user_get($session_id, array('sys_groupid' => $client_groupid));
Hi Till. Thanks, i will look into it right away. I didn't know you could combine the 2, as the second one requires the client_id, which is obtained by the first one. Regards Kris.
Hi Till. I now got everything working'ish. One thing i noticed, is that the client_groupid spits out the correct id, but in the database under sites and ftp user, that specific client_groupid is +1 of what the client_groupid code spits out. is that on purpose or a bug? hope it made sense. Regards Kris.