SOAP API problems in

Discussion in 'Developers' Forum' started by Disassembler, Sep 27, 2012.

  1. Disassembler

    Disassembler New Member

    I have a sizeable Plesk installation to migrate to ISPconfig. Being the type who rather than doing a couple hours of mindless clicking would spend three times that writing code, I set out to write a generic converter that might even benefit others in the same situation. But I'm having problems with the SOAP API, particularly the domains_domain_add function. It always gives me a "permission denied" error even though my API user has every single checkmark for permissions set. I'm not sure whether the problem occurs with other functions too so far as I've only done the bits for clients and domains so far; clients work fine though.

    The problem occurs with both my Perl program and the PHP example by the way. So far I've simply hacked checkPerm() to always return true to be able to go on with development ...

    I'm on a remote island in the Galapagos with rather intermittent internet at the moment, so please excuse any delays in getting back to this thread (and my inability to do any serious debugging on this ISPconfig install running in VirtualBox on my little netbook :)). Just checked out the SVN version to see if it makes a difference though.
  2. till

    till Super Moderator Staff Member ISPConfig Developer

    Please check that the permission "sites_web_domain_add" is listed in the remote_functions field of the remote user in the remote_user table in the ispconfig mysql database.
  3. Disassembler

    Disassembler New Member

    Hi Till,

    thanks for the hint, but yes, it's set. Here's the only record defined:

    [email protected]:~# ssh "mysql -uroot -p123456 -Ddbispconfig -e \"select * from remote_user\\\\G\""
    [email protected]'s password:
    *************************** 1. row ***************************
    remote_userid: 1
    sys_userid: 1
    sys_groupid: 1
    sys_perm_user: riud
    sys_perm_group: riud
    remote_username: apiuser
    remote_password: e10adc3949ba59abbe56e057f20f883e
    remote_functions: server_get,get_function_list,client_templates_get_all,server_get_serverid_by_ip,server_ip_add,server_ip_update,server_ip_delete;client_get,client_add,client_update,client_delete,client_get_sites_by_user,client_get_by_username,client_change_password,client_get_id,client_delete_everything;mail_domain_get,mail_domain_add,mail_domain_update,mail_domain_delete,mail_domain_set_status,mail_domain_get_by_domain;mail_mailinglist_get,mail_mailinglist_add,mail_mailinglist_update,mail_mailinglist_delete;mail_user_get,mail_user_add,mail_user_update,mail_user_delete;mail_alias_get,mail_alias_add,mail_alias_update,mail_alias_delete;mail_forward_get,mail_forward_add,mail_forward_update,mail_forward_delete;mail_catchall_get,mail_catchall_add,mail_catchall_update,mail_catchall_delete;mail_transport_get,mail_transport_add,mail_transport_update,mail_transport_delete;mail_whitelist_get,mail_whitelist_add,mail_whitelist_update,mail_whitelist_delete;mail_blacklist_get,mail_blacklist_add,mail_blacklist_update,mail_blacklist_delete;mail_spamfilter_user_get,mail_spamfilter_user_add,mail_spamfilter_user_update,mail_spamfilter_user_delete;mail_policy_get,mail_policy_add,mail_policy_update,mail_policy_delete;mail_fetchmail_get,mail_fetchmail_add,mail_fetchmail_update,mail_fetchmail_delete;mail_spamfilter_whitelist_get,mail_spamfilter_whitelist_add,mail_spamfilter_whitelist_update,mail_spamfilter_whitelist_delete;mail_spamfilter_blacklist_get,mail_spamfilter_blacklist_add,mail_spamfilter_blacklist_update,mail_spamfilter_blacklist_delete;mail_user_filter_get,mail_user_filter_add,mail_user_filter_update,mail_user_filter_delete;mail_filter_get,mail_filter_add,mail_filter_update,mail_filter_delete;sites_cron_get,sites_cron_add,sites_cron_update,sites_cron_delete;sites_database_get,sites_database_add,sites_database_update,sites_database_delete, sites_database_get_all_by_user;sites_ftp_user_get,sites_ftp_user_add,sites_ftp_user_update,sites_ftp_user_delete;sites_shell_user_get,sites_shell_user_add,sites_shell_user_update,sites_shell_user_delete;sites_web_domain_get,sites_web_domain_add,sites_web_domain_update,sites_web_domain_delete,sites_web_domain_set_status;sites_web_aliasdomain_get,sites_web_aliasdomain_add,sites_web_aliasdomain_update,sites_web_aliasdomain_delete;sites_web_subdomain_get,sites_web_subdomain_add,sites_web_subdomain_update,sites_web_subdomain_delete;dns_zone_get,dns_zone_add,dns_zone_update,dns_zone_delete,dns_zone_set_status,dns_templatezone_add;dns_a_get,dns_a_add,dns_a_update,dns_a_delete;dns_aaaa_get,dns_aaaa_add,dns_aaaa_update,dns_aaaa_delete;dns_alias_get,dns_alias_add,dns_alias_update,dns_alias_delete;dns_cname_get,dns_cname_add,dns_cname_update,dns_cname_delete;dns_hinfo_get,dns_hinfo_add,dns_hinfo_update,dns_hinfo_delete;dns_mx_get,dns_mx_add,dns_mx_update,dns_mx_delete;dns_ns_get,dns_ns_add,dns_ns_update,dns_ns_delete;dns_ptr_get,dns_ptr_add,dns_ptr_update,dns_ptr_delete;dns_rp_get,dns_rp_add,dns_rp_update,dns_rp_delete;dns_srv_get,dns_srv_add,dns_srv_update,dns_srv_delete;dns_txt_get,dns_txt_add,dns_txt_update,dns_txt_delete;vm_openvz

    Hm, I noticed there are some records separated by commas and others by semicolons. That all right?
  4. Disassembler

    Disassembler New Member

    By the way (sorry for bombarding you with questions, gotta get this out as long as teh interwebs are working here), I got a little confused with the API after a while because there's little documentation in terms of semantics. Here's what I didn't find anything on:

    - My tool uses domains_domain_add() so far to add client's domains. But I don't find them associated with clients anywhere in the GUI, plus there are extra functions mail_domain_add() and sites_web_domain_add(). So what's the difference there, and do I have to use domains_domain_add() at all?

    - The client_add() function takes a reseller_id parameter and adding a reseller is a separate form in the GUI, but I don't see how I can add a reseller via the API or indicate that some client is a reseller.

    - There's also a parent_client_id column that I would assume does something similar to the reseller ID, but certainly there's a difference?
  5. Croydon

    Croydon ISPConfig Developer ISPConfig Developer

    domains_domain_add() adds a domain for the client to the domain module (that can be enabled to limit clients to use only their assigned domains).

    sites_domain_add() adds a website

    mail_domain_add() adds a mail domain for creating mailboxes with this domain later on
  6. Disassembler

    Disassembler New Member

    Thanks Marius, that lifted some of the fog already! :)
    Would there happen to be some example or production code that uses the API that I can look at? Because now I'm having some problems figuring out the parameters and particularly their allowed values. E.g. sites_web_domain_add() gives me an "hd_quota_error_empty" error when hd_quota is definitely present but '0' in the SOAP request.

    Other than that, the converter is coming along nicely. Still very unpolished but doing its job. Gonna test it on some real installation and then release it in the coming weeks.
  7. Croydon

    Croydon ISPConfig Developer ISPConfig Developer

    Sure, there are some examples included in the ispconfig download.
    They're in the folder remoting_client/examples/
  8. Disassembler

    Disassembler New Member

    Sure, I know about these ... it's just, they don't really do much. E.g. the client_add script has this "$random_rs_id" parameter that gets passed in as a reseller ID; it's somewhat like in XKCD :) What it doesn't tell me is what I actually need to know: What does that parameter mean? How do I obtain it? Do I pass the ID of an existing client that will thereby automatically be promoted to "reseller", namely of this newly created client, or is this some new ID that will become the reseller ID of the new client? What parameters are obligatory anyway? Apparently you can hand create_client() a parameter called "dafault_mailserver" without causing too much havoc. But then the underlying database is all MYISAM without any referential integrity, so I suppose you can enter quite some bullshit (as long as it passes ISPconfig's validation rules, but I don't think they'll catch nonexistent IDs, do they?) without causing any immediate errors---only later when other scripts expect data to be consistent will your system crash and burn.
    I'd just like to understand what I'm doing before I do it to my production system.
  9. till

    till Super Moderator Staff Member ISPConfig Developer

    The reseller_id is the id of a existing reseller were this client shall be assigned to.

    Yes, because all unkown parameters get discarded automatically.

    All Parameters have to be passed to the function. See database table layout for the full list.

    The remote api is designed as low level api, it is made to allow the developer to pass any parameters to the functions that have a valid type to allow usage scenarios that are not available in the interface. So the you as a developer have to ensure that the parameters that you pass to the function are logically correct.
  10. Disassembler

    Disassembler New Member

    Hi guys,

    thanks for your help so far, work's getting along pretty well. I have a first version on GitHub that migrates clients, domains, mailboxes/forwards and websites. For certain sites (currently that's only Drupal) it can also migrate databases, but I'm still going to generalize that.
    Last edited: Nov 25, 2012

Share This Page