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.

Building new cpanel account via API

Discussion in 'cPanel Developers' started by leonep, Oct 28, 2015.

  1. leonep

    leonep Well-Known Member

    Joined:
    Nov 18, 2014
    Messages:
    46
    Likes Received:
    1
    Trophy Points:
    8
    Location:
    Pescara
    cPanel Access Level:
    Root Administrator
    Hi,
    I am building a web site for manage my hosts. I have my registred users on my own database (mySql) . I have usernames and passwords stored.

    Now i want to use API for create new users in cPanel from php .
    (/json-api/createacct?username=user&domain=example.com&plan=package_name&featurelist=default&quota=0&password=12345luggage&ip=n&cgi=1&hasshell=1&contactemail=user@seconddomain.com&cpmod=x3&maxftp=5&maxsql=5&maxpop=10&maxlst=5&maxsub=1&maxpark=1&maxaddon=1&bwlimit=500&language=en&useregns=1&hasuseregns=1&reseller=0&forcedns=1&mxcheck=local&MAX_EMAIL_PER_HOUR=500&MAX_DEFER_FAIL_PERCENTAGE=80)

    I don't know the correct way to do this , because i have hash passwords in DB and i know it is impossible to reverse.

    Probably it's easy but i need help

    Thanks you very much
     
  2. anton_latvia

    anton_latvia Well-Known Member
    PartnerNOC

    Joined:
    May 11, 2004
    Messages:
    348
    Likes Received:
    3
    Trophy Points:
    18
    Location:
    Latvia
    cPanel Access Level:
    Root Administrator
    You can't reverse mysql passwords.
    If you want to create new accounts on WHM server, all you need is Remote Access Key of the server. I suggest that you look through API - somewhere there were links to ready-php classes, that are great help with various functions, not just account creation.

    With RemoteAccessKey you basically can do a lot of things, as you access your server as root.
     
  3. leonep

    leonep Well-Known Member

    Joined:
    Nov 18, 2014
    Messages:
    46
    Likes Received:
    1
    Trophy Points:
    8
    Location:
    Pescara
    cPanel Access Level:
    Root Administrator
    thanks for reply

    registration.php on my website --> users choose their own password --> verify if choosed password strenght is good for my cpanel setting (required strenght 60)--> store password and user details on my db --> purchase a service --> creation account in cpanel

    i have problem in the last phase i want to create account with password choosed by customers !
    well i can register accounts in cpanel after registration.php because i have password in session but i don't want this i want only after purchase.
    thank you
     
    #3 leonep, Oct 29, 2015
    Last edited: Oct 29, 2015
  4. anton_latvia

    anton_latvia Well-Known Member
    PartnerNOC

    Joined:
    May 11, 2004
    Messages:
    348
    Likes Received:
    3
    Trophy Points:
    18
    Location:
    Latvia
    cPanel Access Level:
    Root Administrator
    I am using this API to make function call more simple:
    cPanel::PublicAPI - search.cpan.org

    Take a look there, there are some examples, including account creation. Let me know, if you can't make it work.
     
  5. leonep

    leonep Well-Known Member

    Joined:
    Nov 18, 2014
    Messages:
    46
    Likes Received:
    1
    Trophy Points:
    8
    Location:
    Pescara
    cPanel Access Level:
    Root Administrator
  6. anton_latvia

    anton_latvia Well-Known Member
    PartnerNOC

    Joined:
    May 11, 2004
    Messages:
    348
    Likes Received:
    3
    Trophy Points:
    18
    Location:
    Latvia
    cPanel Access Level:
    Root Administrator
    in order to create account you need to have either root or reseller password or server remote-access key. May be I don't understand, what you are trying to do.. when you create account - you can set any password you want, but i guess it can not be encrypted, since account creation script will encrypt it..
     
  7. leonep

    leonep Well-Known Member

    Joined:
    Nov 18, 2014
    Messages:
    46
    Likes Received:
    1
    Trophy Points:
    8
    Location:
    Pescara
    cPanel Access Level:
    Root Administrator
    I got a registration page on my website where users choose their own passwords. For security reasons i store in my database the hash of these passwords. After the purchase of services i want to create accounts using api but i have only the hash...

    may be i can random generate password but i must send to customers and is not good to send passwords throught email .I also like to have same password for my customers accounts on website and cpanel customers accounts

    sorry if i was not clear ! thank you very much for your patience
     
  8. anton_latvia

    anton_latvia Well-Known Member
    PartnerNOC

    Joined:
    May 11, 2004
    Messages:
    348
    Likes Received:
    3
    Trophy Points:
    18
    Location:
    Latvia
    cPanel Access Level:
    Root Administrator
    well, that's what I thought, in fact.. ;) well, either you store plain-text password for limited period of time (say 1 hour, so customer can complete registration) or encrypt it with some de-cryptable algorithm. May be option is to store plain text-pw in a separate field or separate database, also for short period of time. I personally don't see other way, sorry.
     
  9. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,678
    Likes Received:
    653
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
Loading...

Share This Page