Create FTP account via API 2 and associate it to a subdomain
Hello everyone,
I have an issue with the API 2 and I can't find a solution. The scenario is:
[LIST]
I create a new subdomain sub.domain.com - everything is okay here (I'm using SubDomain::addsubdomain)
I try to create a new FTP account by using Ftp::addftp but the username will be user@domain.com but I want it to be user@sub.domain.com
How can I achieve this (the documentation does not give me any clues on this)
Thank you in advance!
-
Hello, You can use the "domain" parameter with this API function. EX: cpapi2 --user=$cpanel-user Ftp addftp user=$ftp-user domain=$subdomain.domain.tld pass=$luggage1234567
I've opened an internal case (DOC-9176) with our Documentation Team to ensure this information is reflected on the following document: cPanel API 2 Functions - Ftp::addftp - Software Development Kit - cPanel Documentation Thank you.0 -
Hello, You can use the "domain" parameter with this API function. EX:
cpapi2 --user=$cpanel-user Ftp addftp user=$ftp-user domain=$subdomain.domain.tld pass=$luggage1234567
I've opened an internal case (DOC-9176) with our Documentation Team to ensure this information is reflected on the following document: 530 Login authentication failed". Even if I update the password of the FTP account via cPanel interface, the login still fails... By using the API2, I have created the following FTP account: [LIST]- user@sub.domain.com[/EMAIL]
- some_password When I try to connect, via FTP, to sub.domain.com (with the above credentials), the authentication fails...
0 -
When I try to connect, via FTP, to sub.domain.com (with the above credentials), the authentication fails...
Are you sure the subdomain resolves to the cPanel server? Also, are you including the "@domain.tld" suffix in the username? Do you notice any specific error messages in /var/log/messages when authentication fails? Thank you.0 -
You are right Michael, there was a typo on my side, sorry for that :( Are there any specific parameters I need to send to the API2 so that I can delete this newly created FTP account (by using Ftp::delftp)? Because the deletion of an user in the form of "user@sub.domain.com[/EMAIL]" is not working (but is working for an account like [EMAIL='user@sub.domain.com">user@domain.com[/EMAIL]) 0 -
Hello, You'd also need to define the "domain" parameter in this case: cpapi2 --user=$cpanel-username Ftp delftp user=$ftp-user domain=$sub.domain.tld destroy=1
Also, is there any reason you are using cPanel API 2 over UAPI? We strongly advise using UAPI when possible: UAPI Functions - Ftp::delete_ftp - Software Development Kit - cPanel Documentation Thank you.0 -
Yes, indeed, I've added the domain and it's working just fine. Thanks! As for your question: I'm building a custom interface that allows me to create subdomains, email accounts, ftp users, mysql databases and mysql users (associated to the database) on the fly and I did not manage to find a PHP wrapper built for UAPI. I found one for API2 instead (this one github.com/pguso/cpanel-api/blob/master/src/Hostkit/Common/Api/Cpanel.php)... If you know a PHP wrapper for UAPI that does the same thing, please let me know about it as I don't have any preferences for what API to use as long as I obtain what I need... 0 -
I'm glad to see adding the domain parameter helped. I've also added a note to the Documentation case to ensure the parameter is reflected on the corresponding cPanel API 2 document for the delete FTP account function. I found one for API2 instead (this one cpanel-api/Cpanel.php at master " pguso/cpanel-api " GitHub)... If you know a PHP wrapper for UAPI that does the same thing, please let me know about it as I don't have any preferences for what API to use as long as I obtain what I need...
In the example, you see a entry like this for cPanel API 2:&cpanel_jsonapi_apiversion=2
For UAPI, it's "apiversion=3". So you'd simply adjust the value and make changes to the function names if necessary. Thank you.0 -
Thank your for the advice! I'll try it and get back here afterwords to leave a feedback. 0 -
As a side note: I've studied the UAPI documentation Guide to UAPI - Software Development Kit - cPanel Documentation but I can't find the Subdomains module (apparently you can't manage the subdomains via UAPI) so I'm stuck with API2 for now... (please, do correct me if I'm wrong on this) 0 -
Are there any future plans to include this functionality in UAPI? 0 -
Hello, There's currently no time frame for the availability of a corresponding UAPI function. I encourage you to submit a feature request for the addition of a UAPI function to manage subdomains: Submit A Feature Request Thank you. 0 -
This thread can be marked as Solved. Thank you! 0
Please sign in to leave a comment.
Comments
13 comments