Remote FTP user problem

Discussion in 'Installation/Configuration' started by bmi64, Aug 2, 2016.

  1. bmi64

    bmi64 New Member HowtoForge Supporter

    Hi,
    I'm developping a remote script to create domain, database user, database, and then FTP user and I have an arror I can't solve for this last function :

    data_processing_errordirectory_error_notinweb<br> SOAP Error: directory_error_notinweb



    Here is the function I use to create FTP user :

    PHP:
    $params_Site_FTP_User_add = array(
      
    'server_id'        => $server_id,
      
    'parent_domain_id' => 1,
      
    //'username'         => 'FTP_user'.time(),
      
    'username'         => 'dev_FTP_user'.time(),
      
    'password'         => generateStrongPassword($length 9$add_dashes false$available_sets 'luds'),
      
    'quota_size'       => -1// 1000
      
    'active'           => 'y',
      
    'uid'              => 'web'.$domain_id,// id domaine
      
    'gid'              => 'client'.$client_id,// id client
      
    'dir'              => '/var/www/clients/client'.$client_id.'/web'.$domain_id,
      
    'quota_files'      => -1,
      
    'ul_ratio'         => -1,
      
    'dl_ratio'         => -1,
      
    'ul_bandwidth'     => -1,
      
    'dl_bandwidth'     => -1
    );

    // FUNCTION site FTP user add :
    function site_FTP_user_add($ISP_Soap_id$ISP_Soap_Pass$client$client_id$params_Site_FTP_User_add)
    {
      try {
        if(
    $session_id $client->login($ISP_Soap_id,$ISP_Soap_Pass)) {
          
    //echo 'Logged successfull. Session ID:'.$session_id.'<br />';
        
    }
        
    $affected_rows $client->sites_ftp_user_add($session_id$client_id$params_Site_FTP_User_add);
        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());
      }
    }
    $session_id is created with a previous function, already used in other functions and works correctly.

    If I check the used values, it seems correct :
    the website domain created id : 178
    $domain_id : 178
    $client_id : 1
    'dir' : /var/www/clients/client1/web178


    What's wrong in my code ?

    Thanks for your help !
     
  2. bmi64

    bmi64 New Member HowtoForge Supporter

    If it can inform someone to help me, I print the object $client in my function site_FTP_user_add :
    PHP:
    } catch (SoapFault $e) {
        
    var_dump($client);
        echo 
    $client->__getLastResponse();
        die(
    'SOAP Error: '.$e->getMessage());
      }
    --------------------------------------------------
    Here is the result of var_dump($client) :

    object(SoapClient)[1]
    public 'uri' => string 'https://IPADDRESS:8080/remote/' (length=35)
    public 'location' => string 'https://IPADDRESS:8080/remote/index.php' (length=44)
    public 'trace' => int 1
    public '_soap_version' => int 1
    public 'httpurl' => resource(13, Unknown)
    public '__last_request_headers' => string 'POST /remote/index.php HTTP/1.1

    Host: IPADDRESS:8080

    Connection: Keep-Alive

    User-Agent: PHP-SOAP/5.5.12

    Content-Type: text/xml; charset=utf-8

    SOAPAction: "https://IPADDRESS:8080/remote/#sites_ftp_user_add"

    Content-Length: 2033



    ' (length=246)
    public '__last_response_headers' => string 'HTTP/1.1 500 Internal Service Error

    Date: Thu, 04 Aug 2016 07:13:55 GMT

    Server: Apache/2.4.10 (Debian)

    Pragma: no-cache

    Cache-Control: no-store, no-cache, max-age=0, must-revalidate

    Vary: Accept-Encoding

    Content-Length: 313

    Connection: close

    Content-Type: text/xml; charset=utf-8

    ' (length=289)
    public '__last_request' => string '<?xml version="1.0" encoding="UTF-8"?>
    <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="https://IPADDRESS:8080/remote/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ns2="http://xml.apache.org/xml-soap" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><SOAP-ENV:Body><ns1:sites_ftp_user_add><param0 xsi:type="xsd:string">16b0b78241'... (length=2033)
    public '__last_response' => string '<?xml version="1.0" encoding="UTF-8"?>
    <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"><SOAP-ENV:Body><SOAP-ENV:Fault><faultcode>data_processing_error</faultcode><faultstring>directory_error_notinweb&lt;br&gt;&#13;
    </faultstring></SOAP-ENV:Fault></SOAP-ENV:Body></SOAP-ENV:Envelope>
    ' (length=313)
    public '__soap_fault' =>
    object(SoapFault)[2]
    protected 'message' => string 'directory_error_notinweb<br>

    ' (length=30)
    private 'string' (Exception) => string '' (length=0)
    protected 'code' => int 0
    protected 'file' => string 'E:\wamp\www\ispconfig-remote\remote-api.php' (length=43)
    protected 'line' => int 308
    private 'trace' (Exception) =>
    array (size=4)
    0 =>
    array (size=6)
    ...
    1 =>
    array (size=6)
    ...
    2 =>
    array (size=4)
    ...
    3 =>
    array (size=4)
    ...
    private 'previous' (Exception) => null
    public 'faultstring' => string 'directory_error_notinweb<br>

    ' (length=30)
    public 'faultcode' => string 'data_processing_error' (length=21)
    public 'xdebug_message' => string '<tr><th align='left' bgcolor='#f57900' colspan="5"><span style='background-color: #cc0000; color: #fce94f; font-size: x-large;'>( ! )</span> SoapFault: directory_error_notinweb&lt;br&gt;

    in E:\wamp\www\ispconfig-remote\remote-api.php on line <i>308</i></th></tr>
    <tr><th align='left' bgcolor='#e9b96e' colspan='5'>Call Stack</th></tr>
    <tr><th align='center' bgcolor='#eeeeec'>#</th><th align='left' bgcolor='#eeeeec'>Time</th><th align='left' bgcolor='#eeeeec'>Memory</th><th align='left' bgcolor='#eeeeec'>Fun'... (length=2184)

    data_processing_errordirectory_error_notinweb<br> SOAP Error: directory_error_notinweb


    -----------------------------------------------------

    I don't see my error with this information :confused:
     
  3. bmi64

    bmi64 New Member HowtoForge Supporter

    I try again to solve my problem, hope someone can help me

    Here they are, hope it helps :

    - Linux Distribution and version used on your server.
    - ISPConfig version

    Debian
    and a issue command give me this informations, as asked in https://www.howtoforge.com/community/threads/please-read-before-posting.58408/ :
    Linux xxxx 3.14.32-xxxx-grs-ipv6-64 #7 SMP Wed Jan 27 18:05:09 CET 2016 x86_64 GNU/Linux
    8.5


    And here is the report for the command:
    cat htf_report.txt | more

    ##### SERVER #####
    IP-address (as per hostname): ***.***.***.***
    IP-address(es) (as per ifconfig): ***.***.***.***
    [INFO] ISPConfig is installed.

    ##### ISPCONFIG #####
    ISPConfig version is 3.0.5.4p9

    ##### VERSION CHECK #####

    [INFO] php (cli) version is 5.6.24-0+deb8u1
    [INFO] php-cgi (used for cgi php in default vhost!) is version 5.6.24-0+deb8u1

    ##### PORT CHECK #####

    ##### MAIL SERVER CHECK #####

    ##### RUNNING SERVER PROCESSES #####

    [INFO] I found the following web server(s):
    Apache 2 (PID 13012)
    [INFO] I found the following mail server(s):
    Postfix (PID 12164)
    [INFO] I found the following pop3 server(s):
    Dovecot (PID 13143)
    [INFO] I found the following imap server(s):
    Dovecot (PID 13143)
    [INFO] I found the following ftp server(s):
    PureFTP (PID 10094)

    ##### LISTENING PORTS #####
    (seulement ()
    Adresse (distante)
    [localhost]:10025 (12164/master)
    [anywhere]:3306 (11075/mysqld)
    [anywhere]:587 (12164/master)
    [localhost]:11211 (25698/memcached)
    [anywhere]:110 (13143/dovecot)
    [anywhere]:143 (13143/dovecot)
    [anywhere]:465 (12164/master)
    [anywhere]:21 (10094/pure-ftpd)
    ***.***.***.***:53 (9822/named)
    [localhost]:53 (9822/named)
    [anywhere]:22 (13169/sshd)
    [anywhere]:25 (12164/master)
    [localhost]:953 (9822/named)
    [anywhere]:993 (13143/dovecot)
    [anywhere]:995 (13143/dovecot)
    [localhost]:10024 (1076/amavisd-new)
    *:*:*:*::*:587 (12164/master)
    [localhost]10 (13143/dovecot)
    [localhost]43 (13143/dovecot)
    *:*:*:*::*:8080 (13012/apache2)
    *:*:*:*::*:80 (13012/apache2)
    *:*:*:*::*:8081 (13012/apache2)
    *:*:*:*::*:465 (12164/master)
    *:*:*:*::*:21 (10094/pure-ftpd)
    *:*:*:*::*:53 (9822/named)
    *:*:*:*::*:22 (13169/sshd)
    *:*:*:*::*:25 (12164/master)
    *:*:*:*::*:953 (9822/named)
    *:*:*:*::*:443 (13012/apache2)
    *:*:*:*::*:993 (13143/dovecot)
    *:*:*:*::*:995 (13143/dovecot)
    *:*:*:*::*:10024 (1076/amavisd-new)

    ##### IPTABLES #####
    Chain INPUT (policy ACCEPT)
    target prot opt source destination
    fail2ban-squirrelmail tcp -- [anywhere]/0 [anywhere]/0 multiport dports
    80,443
    fail2ban-pureftpd tcp -- [anywhere]/0 [anywhere]/0 multiport dports 21
    fail2ban-dovecot-pop3imap tcp -- [anywhere]/0 [anywhere]/0 multiport dp
    orts 110,995,143,993
    fail2ban-postfix tcp -- [anywhere]/0 [anywhere]/0 multiport dports 25,4
    65,587
    fail2ban-ssh tcp -- [anywhere]/0 [anywhere]/0 multiport dports 22

    Chain FORWARD (policy ACCEPT)
    target prot opt source destination

    Chain OUTPUT (policy ACCEPT)
    target prot opt source destination

    Chain fail2ban-dovecot-pop3imap (1 references)
    target prot opt source destination
    RETURN all -- [anywhere]/0 [anywhere]/0

    Chain fail2ban-postfix (1 references)
    target prot opt source destination
    RETURN all -- [anywhere]/0 [anywhere]/0

    Chain fail2ban-pureftpd (1 references)
    target prot opt source destination
    RETURN all -- [anywhere]/0 [anywhere]/0

    Chain fail2ban-squirrelmail (1 references)
    target prot opt source destination
    RETURN all -- [anywhere]/0 [anywhere]/0

    Chain fail2ban-ssh (1 references)
    target prot opt source destination
    RETURN all -- [anywhere]/0 [anywhere]/0


    • I've changed ISP log to debug level in case it can help, following your advice.

    • And then I changed my script to make it more simple to just add a new FTP user :
    • the existing website is test-ip.fr, id='136',
    • Client for this website is id='1' :

    And here is the simplified script, following API-Docs :

    PHP:
    $ISP = array(
        
    'debug'     => '1',
        
    'host'      => 'xxx.xxx.xxx.xxx',
        
    'soap_id'   => 'dev',
        
    'soap_pass' => 'lnbpqNPUP!E46',
        
    'ndd'       => 'test-ip.fr',
        
    'ip'        => ''
        
    );

    $params_Site_FTP_User_add = array(
      
    'server_id'        => '1',
      
    'parent_domain_id' => 1,
      
    'username'         => 'dev_FTP_user',
      
    'password'         => 'password',
      
    'quota_size'       => -1,
      
    'active'           => 'y',
      
    'uid'              => 'web136',
      
    'gid'              => 'client1',
      
    'dir'              => '/var/www/clients/client1/web136',
      
    'quota_files'      => -1,
      
    'ul_ratio'         => -1,
      
    'dl_ratio'         => -1,
      
    'ul_bandwidth'     => -1,
      
    'dl_bandwidth'     => -1
    );

    $ISP_Soap_Location         'https://'.$ISP['host'].':8080/remote/index.php';
    $ISP_Soap_Uri              'https://'.$ISP['host'].':8080/remote/';

    $client = new SoapClient(null, array('location' => $ISP_Soap_Location,
        
    'uri'      => $ISP_Soap_Uri,
        
    'trace' => 1,
        
    'exceptions' => 1));

    try {
      if(
    $session_id $client->login('dev''lnbpqNPUP!E46')) {
        echo 
    'Logged successfull. Session ID:'.$session_id.'<br />';
      }

      
    //* Set the function parameters.
      
    $client_id 1;

      
    $params = array(
        
    'server_id' => 1,
        
    'parent_domain_id' => 1,
        
    'username' => 'tom',
        
    'password' => 'secret',
        
    'quota_size' => 10000,
        
    'active' => 'y',
        
    'uid'              => 'web136',// id domaine
        
    'gid'              => 'client1',//.$client_id,// id client
        
    'dir' => '/var/www/clients/client1/web136',
        
    'quota_files' => -1,
        
    'ul_ratio' => -1,
        
    'dl_ratio' => -1,
        
    'ul_bandwidth' => -1,
        
    'dl_bandwidth' => -1
      
    );

      
    $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());
    }

    Here here the result of the script :

    Logged successfull. Session ID:303a900a398bff4c615de145702d5275
    data_processing_errordirectory_error_notinweb<br> SOAP Error: directory_error_notinweb

    Can someone help me to solve this problem ? Thanks !
     
  4. bmi64

    bmi64 New Member HowtoForge Supporter

    I just subscribed to howtoforge.
     
  5. bmi64

    bmi64 New Member HowtoForge Supporter

    ! help please, I really don'tunderstand why my script doesn't work !
    I'm still working on it, trying to change some params, but the error message doesn't change.
    The script I use is the same (I think) as API-doc, shown in my last post is like , but still getting the same error message :/
    hope to get help to find an issue.
     
  6. florian030

    florian030 ISPConfig Developer ISPConfig Developer

    You script is working. Just make sure, that server_id and parent_domain_id matches the record for dir in your $params array. BTW: 'password' => 'secret', won't work because secret will not match the security-limits.
     
  7. bmi64

    bmi64 New Member HowtoForge Supporter

    Thanks for your help Florian030 !
    I've changed the password and the error report is smaller now but the script still doesn't works :(
    SOAP Error: directory_error_notinweb

    I suppose it's relative to 'parent_domain_id' but I don't kno where to find it, even with the ISP configuration documentation that I bought :confused:
    Here is my script, almost the same exept FTP user password (created in ISP window) that should be fine now, and I removed quotes to 'server_id' => 1

    Where can I find server_id and parent_domain_id ?

    PHP:
    $username 'dev';
    $password 'lnbpqNPUP!E46';
    $soap_location 'https://xxx.xxx.xxx.xxx:8080/remote/index.php';
    $soap_uri 'https://xxx.xxx.xxx.xxx:8080/remote/';

    $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 />';}

        
    $client_id 1;

        
    $params = array(
            
    'server_id'        => 1,// → CHANGED : deleted quotes
            
    'parent_domain_id' => 1,
            
    'username'         => 'tom',
            
    //'password'         => 'secret',
            
    'password'         => 'IMiwHf3'→ CHANGED created in ISP window manually
            
    'quota_size'       => -1,
            
    'active'           => 'y',
            
    'uid'              => 'web136',
            
    'gid'              => 'client1',
            
    'dir'              => '/var/www/clients/client1/web136',
            
    'quota_files'      => -1,
            
    'ul_ratio'         => -1,
            
    'dl_ratio'         => -1,
            
    'ul_bandwidth'     => -1,
            
    'dl_bandwidth'     => -1
        
    );

        
    $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();
        
    var_dump($client);
        die(
    'SOAP Error: '.$e->getMessage());
    }
    Here is the configuration of website :
    [​IMG]
     
  8. florian030

    florian030 ISPConfig Developer ISPConfig Developer

    You can get the domain with something like
    $tmp = $remote->sites_web_domain_get($session_id,array('domain' => "example.com"));

    Why don't you create an ftp-user within ispconfig and check the new entry in the db-table ftp_user?
     
  9. bmi64

    bmi64 New Member HowtoForge Supporter

    That's it ! I was blocked by parent_domain_id and finally found it in the manually created FTP user for the same website.

    Thank you VERY MUCH !
     

Share This Page