The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

SOLVED Create FTP account via API 2 and associate it to a subdomain

Discussion in 'cPanel Developers' started by liviuhariton, Jul 4, 2017.

Tags:
  1. liviuhariton

    liviuhariton Member

    Joined:
    Jul 4, 2017
    Messages:
    8
    Likes Received:
    1
    Trophy Points:
    3
    Location:
    Tulcea, Romania
    cPanel Access Level:
    Root Administrator
    Hello everyone,

    I have an issue with the API 2 and I can't find a solution. The scenario is:
    • 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!
     
  2. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    37,186
    Likes Received:
    1,295
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    liviuhariton likes this.
  3. liviuhariton

    liviuhariton Member

    Joined:
    Jul 4, 2017
    Messages:
    8
    Likes Received:
    1
    Trophy Points:
    3
    Location:
    Tulcea, Romania
    cPanel Access Level:
    Root Administrator
    Awesome, thank you! With the new parameter the username is now created as I wanted.

    BUT, there is a new problem: when I try to login with the newly created credentials the authentication fails with "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:
    When I try to connect, via FTP, to sub.domain.com (with the above credentials), the authentication fails...
     
  4. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    37,186
    Likes Received:
    1,295
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    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.
     
  5. liviuhariton

    liviuhariton Member

    Joined:
    Jul 4, 2017
    Messages:
    8
    Likes Received:
    1
    Trophy Points:
    3
    Location:
    Tulcea, Romania
    cPanel Access Level:
    Root Administrator
    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" is not working (but is working for an account like user@domain.com)
     
  6. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    37,186
    Likes Received:
    1,295
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
  7. liviuhariton

    liviuhariton Member

    Joined:
    Jul 4, 2017
    Messages:
    8
    Likes Received:
    1
    Trophy Points:
    3
    Location:
    Tulcea, Romania
    cPanel Access Level:
    Root Administrator
    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...
     
    #7 liviuhariton, Jul 4, 2017
    Last edited by a moderator: Jul 5, 2017
  8. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    37,186
    Likes Received:
    1,295
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    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.

    In the example, you see a entry like this for cPanel API 2:

    Code:
    &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.
     
  9. liviuhariton

    liviuhariton Member

    Joined:
    Jul 4, 2017
    Messages:
    8
    Likes Received:
    1
    Trophy Points:
    3
    Location:
    Tulcea, Romania
    cPanel Access Level:
    Root Administrator
    Thank your for the advice! I'll try it and get back here afterwords to leave a feedback.
     
  10. liviuhariton

    liviuhariton Member

    Joined:
    Jul 4, 2017
    Messages:
    8
    Likes Received:
    1
    Trophy Points:
    3
    Location:
    Tulcea, Romania
    cPanel Access Level:
    Root Administrator
  11. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    37,186
    Likes Received:
    1,295
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    That's correct. Some cPanel API 2 functions are not yet supported with cPanel UAPI. This includes the ability to add subdomains.

    Thank you.
     
  12. liviuhariton

    liviuhariton Member

    Joined:
    Jul 4, 2017
    Messages:
    8
    Likes Received:
    1
    Trophy Points:
    3
    Location:
    Tulcea, Romania
    cPanel Access Level:
    Root Administrator
    Are there any future plans to include this functionality in UAPI?
     
  13. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    37,186
    Likes Received:
    1,295
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    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.
     
  14. liviuhariton

    liviuhariton Member

    Joined:
    Jul 4, 2017
    Messages:
    8
    Likes Received:
    1
    Trophy Points:
    3
    Location:
    Tulcea, Romania
    cPanel Access Level:
    Root Administrator
    This thread can be marked as Solved. Thank you!
     
    cPanelMichael likes this.
Loading...

Share This Page