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!

API access with user credentials rather than root/reseller

Discussion in 'cPanel Developers' started by rajuru, Nov 15, 2010.

  1. rajuru

    rajuru Active Member

    Joined:
    Nov 13, 2005
    Messages:
    25
    Likes Received:
    0
    Trophy Points:
    151
    Hello,
    Currently, we had to provide root/reseller username and password/hash to access cpanel api using:
    Code:
    ->password_auth()
    ->hash_auth();
    however, can't I login as normal user?

    I need to do some tasks that are allowed for users. they are like, adding email, database, subdomains. I mean just subdomain features. How can I do this using API without root/reseller privileges?

    Thanks in advance.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  2. cPanelDavidN

    cPanelDavidN Integration Developer

    Joined:
    Dec 17, 2009
    Messages:
    571
    Likes Received:
    3
    Trophy Points:
    68
    Location:
    Houston, TX
    cPanel Access Level:
    Root Administrator
    Hi rajuru,

    By default the XML-API PHP class connects to a WHM port, 2087.

    If you use one of the cPanel ports and supply the user credentials, you should be able to perform API1 and API2 functions via the XML-API.
    Code:
    /// setup here///
    
    //  alter setup for cPanel as user //
    $xmlapi->set_port('2083');
    $xmlapi->password_auth("someone","S3cret!pass123");
    
    
    // ...and a way we go! //
    
    $add = array(
     'email' => "testname",
     'password' => "EmailS3cr3t!",
     'domain' => "thisdomain.com",
     'quota' => 0
    );
    
    $result = $xmlapi->api2_query( 'someone', 'Email', 'addpop', $add );
    
    Best Regards,
    -DavidN
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  3. rajuru

    rajuru Active Member

    Joined:
    Nov 13, 2005
    Messages:
    25
    Likes Received:
    0
    Trophy Points:
    151
    Thanks a lot DavidN. It will surely save my ass. I will test it soon and let you know.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  4. rajuru

    rajuru Active Member

    Joined:
    Nov 13, 2005
    Messages:
    25
    Likes Received:
    0
    Trophy Points:
    151
    Hello,
    It is working superb! Thanks a lot for your help. Otherwise I would be in serious problems.

    Thanks
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
    #4 rajuru, Nov 16, 2010
    Last edited: Nov 16, 2010
  5. cPanelDavidN

    cPanelDavidN Integration Developer

    Joined:
    Dec 17, 2009
    Messages:
    571
    Likes Received:
    3
    Trophy Points:
    68
    Location:
    Houston, TX
    cPanel Access Level:
    Root Administrator
    No problem, glad I could help!:D

    Best Regards,
    -DavidN
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
Loading...

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