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.

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:
    1
    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:
    1
    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 Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,706
    Likes Received:
    658
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
Loading...

Share This Page