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.

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:
    1
    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.
     
  2. cPanelDavidN

    cPanelDavidN Integration Developer
    Staff Member

    Joined:
    Dec 17, 2009
    Messages:
    571
    Likes Received:
    1
    Trophy Points:
    18
    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
     
  3. rajuru

    rajuru Active Member

    Joined:
    Nov 13, 2005
    Messages:
    25
    Likes Received:
    0
    Trophy Points:
    1
    Thanks a lot DavidN. It will surely save my ass. I will test it soon and let you know.
     
  4. rajuru

    rajuru Active Member

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

    Thanks
     
    #4 rajuru, Nov 16, 2010
    Last edited: Nov 16, 2010
  5. cPanelDavidN

    cPanelDavidN Integration Developer
    Staff Member

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

    Best Regards,
    -DavidN
     
Loading...

Share This Page