problems with remoting examples

Discussion in 'ISPConfig 3 Priority Support' started by saco721, Mar 29, 2016.

  1. saco721

    saco721 Member HowtoForge Supporter

    Hi I have multi-server setup on debian squeeze with ispconfig 3.0.5.4p8. I have the following files for remoting example :

    soap_config.php
    Code:
    <?php
    $username = 'michael';
    $password = 'michaelspassword';
    $soap_location = 'https://127.0.0.1:8080/remote/index.php';
    $soap_uri = 'https://127.0.0.1:8080/remote/';
    ?>
    
    sites_ftp_user_add.php

    When I open sites_ftp_user_add.php I get :

    Code:
    Logged successfull. Session ID:cb3a190bf4fb81f2334d2bed77fd86eb
    data_processing_errorinvalid_system_user_or_group_txt<br>
    invalid_system_user_or_group_txt<br>
    directory_error_regex<br />
    directory_error_notinweb<br>
    SOAP Error: invalid_system_user_or_group_txt
    invalid_system_user_or_group_txt
    directory_error_regex
    directory_error_notinweb
    A remote user has been added with all functions selected.

    I have tried adding different soap user names and passwords but still get the same result. Any help would be greatly appreciated.
     
    Last edited: Mar 29, 2016
  2. till

    till Super Moderator Staff Member ISPConfig Developer

    Change the parameter "dir" in the $params array, this has to contain the directory that the FTP user can access, e.g. /var/www/clients/client1/web1

    And change "uid" to the web user e.g. "web1" and "gid" to the group e.g. "client1" in the params array.
     
  3. saco721

    saco721 Member HowtoForge Supporter

    Hey Till,
    made changes as you suggested, and the errors have gone, I now get :
    But when I log in to ispconfig and go to FTP users, a field is created for the user but Server, Website and Username are empty, please help
     
  4. till

    till Super Moderator Staff Member ISPConfig Developer

    Create an ftp user in ispconfig interface, then take a look into the ftp_user database table to check out the fields that ispconfig has set and then adjust the values of the $params array in your api call accordingly. You can use all parameters except of the sys_* columns of the database table in $params array.
     
  5. saco721

    saco721 Member HowtoForge Supporter

    Hey Till,
    I added a new ftp user and looked at the ftp_user table to see what fields ispconfig has set, it is correct as expected, the problem is that the script is being executed, but it isn't picking up the values from the params array.. I have tried changing the values, for example setting active from 'y' to 'n' but it remains the same. I have looked at the ISPConfig 3 remote API documentation to check the Parameters (in $params) and all 14 are there. What else can I try?
     
  6. till

    till Super Moderator Staff Member ISPConfig Developer

    Your example script above is about adding an FTP user (function sites_ftp_user_add). If you want to dify an existing user, you have to use the function sites_ftp_user_update.
     
  7. saco721

    saco721 Member HowtoForge Supporter

    Thanks for your time Till, but what I want to do is add a new ftp user not modify an existing one, that is why I was using function sites_ftp_user_add.
     
  8. till

    till Super Moderator Staff Member ISPConfig Developer

    Then use the sites_ftp_user_add function. The function gets its values from $params array only, it can not get values from somewhere else. Maybe you tried to add a FTP user with the same name again which is not possible off course and therefor no new user gets added so that you still see your old first user with wrong values.
     
  9. saco721

    saco721 Member HowtoForge Supporter

    Hi Till,
    I have ensured that I did not enter the same user name, but still get the same result, the required fields are not being populated.

    I was wondering if I should use :

    Code:
    $affected_rows = $client->sites_ftp_user_add($session_id, $client_id, $params);
    instead of :
    Code:
    $affected_rows = $client->sites_ftp_user_add($session_id, $client_id, $params_ftp);
    thanks.
     
  10. till

    till Super Moderator Staff Member ISPConfig Developer

    That depends on the name that you have chosen for your params array. In the example script from above, the array is named $params. If you have written a new script and named the array $params_ftp now, then the variable name that is passed to the sites_ftp_user_add function has to be $params_ftp as well.

    But there is a new record in the database each time that you execute the api script?

    You said that you did not enter the user name, the user name is required, so you have to set it in the $params array and it has to be unique.
     
  11. saco721

    saco721 Member HowtoForge Supporter

    Hi Till,
    The following script doesn't work, the username testftp is unique.

    Code:
    <?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 />';
    }
    $myname = 'testftp';
    $mypassword = 'password';
    
    $client_id = 1;
    
    
    
    $params = array(
    'server_id' => '1',
    'parent_domain_id' => '1',
    'username' => $myname,
    'password' => $mypassword,
    'quota_size' => '-1',
    'active' => 'y',
    'uid' => 'web16',
    'gid' => 'client0',
    'dir' => '/var/www/clients/client0/web16',
    'quota_files' => '100',
    'ul_ratio' => '-1',
    'dl_ratio' => '200',
    'ul_bandwidth' => '-1',
    'dl_bandwidth' => '100',
    );
    
    $affected_rows = $client->sites_ftp_user_add($session_id, $client_id, $params);
    
    
    echo "FTP User ID: ".$affected_rows."<br>";
    
    
    
    
    if($client->logout($session_id)) {
    echo 'Logged out.<br />';
    }
    
    
    } catch (SoapFault $e) {
    echo $client->__getLastResponse();
    die('SOAP Error: '.$e->getMessage());
    }
    
    ?>
    It should call sites_ftp_user_add function in remoting.inc.php and insert a record into the ftp_user table, instead I get the following error :
    Code:
    Logged successfull. Session ID:8ebc09b8819186c54ef93f3f19317cd1
    data_processing_errordirectory_error_notinweb<br>
    SOAP Error: directory_error_notinweb
    However the following script :

    Code:
    <?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 />';
    }
    
    $myname = 'testftp';
    $mypassword = 'password';
    
    $client_id = 1;
    
    
    
    $params = array(
    'server_id' => '1',
    'parent_domain_id' => '1',
    'username' => $myname,
    'password' => $mypassword,
    'quota_size' => '-1',
    'active' => 'y',
    'uid' => 'web16',
    'gid' => 'client0',
    'dir' => '/var/www/clients/client0/web16',
    'quota_files' => '100',
    'ul_ratio' => '-1',
    'dl_ratio' => '200',
    'ul_bandwidth' => '-1',
    'dl_bandwidth' => '100',
    );
    
    $affected_rows = $client->sites_ftp_user_add($session_id, $client_id, $params_ftp);
    
    
    echo "FTP User ID: ".$affected_rows."<br>";
    
    
    
    
    if($client->logout($session_id)) {
    echo 'Logged out.<br />';
    }
    
    
    } catch (SoapFault $e) {
    echo $client->__getLastResponse();
    die('SOAP Error: '.$e->getMessage());
    }
    
    ?>
    produces the following message :

    Code:
    Logged successfull. Session ID:7e885c257132af7c940650306f763c92
    FTP User ID: 182
    Logged out.
    It calls the function and inserts a record into the database, but the record looks like this (the NULL fields are username, password, uid, gid, dir), the only correct field is ftp_user_id at the beginning (182) :

    Code:
    18200riudriud 00NULL NULL-1yNULLNULLNULL-1-1-1-1-10000-00-00 00:00:00
    instead of the following correct record that was inserted using add ftp user in ISPConfig :

    Code:
    132 1 0 riud riud   1 24 defaulttest default $1$CGgHUNty$4TObg7YvJgA944Qslubtg0 -1 y web24 client0 /var/www/clients/client0/web24 -1 -1 -1 -1 -1 0000-00-00 00:00:00
    I can see that the params array is not being passed to sites_add_ftp_user, as $affected_rows = $client->sites_ftp_user_add($session_id, $client_id, $params_ftp); uses $params_ftp instead of $params. But if I change it to $affected_rows = $client->sites_ftp_user_add($session_id, $client_id, $params); I just get errrors.

    Where is the script going wrong?, thanks.
     
  12. till

    till Super Moderator Staff Member ISPConfig Developer

    This means that the path that you have set is not in the website. you told the api that the website is owned by client 1:

    $client_id = 1;

    and later in the params array you say the script that the client is 0 and not 1:

    'dir' => '/var/www/clients/client0/web16',

    so the path of the website that you have set for this FTP user is not a path of this client and therefore the script rejected to insert the ftp user.

    So if the webiste "1" is owned by the admin user and not a client, then the client_id has to be 0 and not 1.
     
  13. saco721

    saco721 Member HowtoForge Supporter

    Hi Till,
    first of all thank you for your patience.
    I have modified the script to :
    Code:
    <?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 />';
    }
    
    $myname = 'testftp';
    $mypassword = 'password';
    
    $client_id = 0;
    
    $params = array(
    'server_id' => '1',
    'parent_domain_id' => '1',
    'username' => $myname,
    'password' => $mypassword,
    'quota_size' => '-1',
    'active' => 'y',
    'uid' => 'web16',
    'gid' => 'client0',
    'dir' => '/var/www/clients/client0/web16',
    'quota_files' => '100',
    'ul_ratio' => '-1',
    'dl_ratio' => '200',
    'ul_bandwidth' => '-1',
    'dl_bandwidth' => '100',
    );
    
    $affected_rows = $client->sites_ftp_user_add($session_id, $client_id, $params);
    
    
    echo "FTP User ID: ".$affected_rows."<br>";
    
    
    
    
    if($client->logout($session_id)) {
    echo 'Logged out.<br />';
    }
    
    
    } catch (SoapFault $e) {
    echo $client->__getLastResponse();
    die('SOAP Error: '.$e->getMessage());
    }
    
    ?>
    I still get the error message :

     
  14. till

    till Super Moderator Staff Member ISPConfig Developer

    Which document_root directory is set for the website with domain_id = 1 in the web_domain table?
     
  15. saco721

    saco721 Member HowtoForge Supporter

    Hi Till,

    There is no record for domain_id = 1, set domain_id to 16 in sites_ftp_user_add.php and the record is now there, thanks for your help Till :)
     
    Last edited: Apr 4, 2016

Share This Page