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!

Change email account password using API 2 with reseller credentials

Discussion in 'cPanel Developers' started by marcochiesi, Oct 8, 2014.

  1. marcochiesi

    marcochiesi Member

    Joined:
    Mar 1, 2011
    Messages:
    23
    Likes Received:
    0
    Trophy Points:
    51
    Location:
    Italy
    cPanel Access Level:
    Root Administrator
    Twitter:
    Hello,
    I'd like to implement the ability to change the email password from within Roundcube using the cpanel password driver plugin included in Roundcube. I also would like to have a unique shared instance of Roundube for a set of cPanel accounts owned by the same reseller.
    After having configured everything I noticed that unfortunately it looks like that API 2 requires the cPanel account credentials, while it doesn't work using reseller (owner) credentials.
    I also made some test with custom code calling Email::passwordpop using xmlapi.php, which seems to confirm this. When I try to run it with the reseller credentials I get the following error:
    Is there a way for a reseller to change email password of the owned account using API 2?

    Any help would be appreciated. Thanks!
     
  2. marcochiesi

    marcochiesi Member

    Joined:
    Mar 1, 2011
    Messages:
    23
    Likes Received:
    0
    Trophy Points:
    51
    Location:
    Italy
    cPanel Access Level:
    Root Administrator
    Twitter:
    If anyone out there is interested in this, I finally was able to find a solution (thanks also to cPanel support team).

    I made a modified copy of the roundcube's cpanel password driver (plugins/password/drivers/cpanel.php), anche changed the setPassword as follows:

    PHP:
        function setPassword($address$password)
        {
            if (
    strpos($address'@')) {
                list(
    $data['email'], $data['domain']) = explode('@'$address);
            }
            else {
                list(
    $data['email'], $data['domain']) = array($address'');
            }

            
    $data['password'] = $password;

            
    // first get cpanel user from domain
            
    $query $this->xmlapi->listaccts('domain'$data['domain']);
            
    $query json_decode($querytrue);
            if(
    $query['status'] != 1) return false;
            
    $cpanel_user $query['acct'][0]['user'];

            
    // then we update password
            
    $query $this->xmlapi->api2_query($cpanel_user'Email''passwdpop'$data);
            
    $query json_decode($querytrue);

            if (
    $query['cpanelresult']['data'][0]['result'] == 1) {
                return 
    true;
            }

            return 
    false;
        }
    P.s. In roundcube config file you must use port 2087 and put reseller credentials for this to work.
     
  3. cPanelMichael

    cPanelMichael Technical Support Community Manager
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    44,802
    Likes Received:
    1,896
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Twitter:
    I am happy to see you were able to find a solution. Thank you for updating us with the outcome.
     
    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