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.

Using root account with api2 to addpop to a given user

Discussion in 'cPanel Developers' started by robjacoby, Aug 22, 2011.

  1. robjacoby

    robjacoby Registered

    Joined:
    Aug 22, 2011
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    1
    Hi all,

    I am looking to use the php publicAPI library found at https://github.com/CpanelInc/publicapi-php to add mail accounts for a user. I want to be able to do this using the root login however whenever I try to make any api1 or api2 calls using the root login, I get Access Denied. For example:

    PHP:
    $this->cp Cpanel_PublicAPI::getInstance($this->getOptions()); //where $this->getOptions() contains all relevant params ie, host, user, pass

    public function createEmail($username$email$password$domain$quota 100)
        {
            
    $queryMf = array(
                
    'module'    => 'Email',
                
    'function'  => 'addpop',
                
    'user'      => $username,
            );

            
    $queryParams = array(
                
    'domain'    => $domain,
                
    'email'     => $email,
                
    'password'  => $password,
                
    'quota'     => $quota,
            );

            
    $response $this->cp->cpanel_api2_request('cpanel'$queryMf$queryParams);
            
            
    var_dump($response);
        }
    when calling createEmail with all relevant params, I get the Access Denied response using the root login. If I change the authentication details to the user and pass of the user I want to add the pop account for, it works fine.

    Is this by design? Or am I simply doing something wrong.

    It should also be important to note, that using the root login, any whm_api calls work fine.
     
  2. MattDees

    MattDees cPanel Product Owner
    Staff Member

    Joined:
    Apr 29, 2005
    Messages:
    417
    Likes Received:
    1
    Trophy Points:
    18
    Location:
    Houston, TX
    cPanel Access Level:
    Root Administrator
    in your cpanel_api2_request line change "cpanel" to "whostmgr"

    root cannot authenticate against cpanel properly, if that does not fix it, please let me know and I'll ask the developer of that class to take a look at it.
     
Loading...

Share This Page