Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

The Community Forums

Interact with an entire community of cPanel & WHM users!

WHM Account Creation API Issue

Discussion in 'cPanel Developers' started by webdes03, May 4, 2013.

  1. webdes03

    webdes03 Member

    Nov 24, 2004
    Likes Received:
    Trophy Points:
    I've been pulling my hair out on this all day, and I'm wondering if there's any chance there's a bug in the API.

    We're on build 5 of WHM 11.36.1, and we're building our own management utility to handle back-end account creation, support, etc. We're using curl throughout our utility to surface account details and information from WHM and cPanel, with no issues at all, but we're seeing some very strange behavior when using the API to create accounts.

    We automatically generate random 8 character usernames, and random secure passwords, which are pushed to the curl url during execution. We're doing this all behind https, using the WHM accesshash for authentication (just like all of our other curl calls).

    $newAcct curl_init();
    $newAcctHeader[0] = "Authorization: WHM root:".preg_replace("'(\r|\n)'","",$accesshash);
    $result curl_exec($newAcct);

    if (
    strpos($result"...Done") === false) {
    alert_bar('Error creating hosting account ('.$username.'). ('.$result.')','red');
    Every single time we execute this, it tells us the username is already being used (and errors), but creates the account anyway. As an example...

    The script generated a username of "ofme7bwe" and attempted to create an account for the domain "". Neither the domain or user exists in the system. The script did create the account, but the output of the API shows it failed because of the user.

    {"result":[{"options":null,"statusmsg":"Sorry, a group for that username already exists.","status":0,"rawout":null}]}
    We're relying on the WHM API output to either halt or continue the configuration of the account, so this "false positive" is holding up the entire script even though it seems to successfully build the account.

    Any thoughts?
    #1 webdes03, May 4, 2013
    Last edited: May 4, 2013
  2. KostonConsulting

    KostonConsulting Well-Known Member

    Jun 17, 2010
    Likes Received:
    Trophy Points:
    San Francisco, CA
    cPanel Access Level:
    Root Administrator
    Are you able to add the accounts via WHM UI? This API call is likely just a wrapper around that same account creation process.

    Are you sure that group doesn't actually exist? If you're using "random" names, you may have some collisions as there are only 8 characters.

    cat /etc/group | grep "ofme7bwe"

    I ran some tests and have 0 issues creating accounts on
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice