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 2 MysqlFE userdbprivs problems

Discussion in 'cPanel Developers' started by elia, Aug 13, 2010.

  1. elia

    elia Registered

    Joined:
    Aug 13, 2010
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    1
    Hi,

    I have a problem with the userdbprivs api2 function of MysqlFE module.
    I use CPanel 11.25.0-STABLE version and I use Xmlapi php library.
    This is my call:
    Code:
    $ret = $xmlapi->api2_query($account, "MysqlFE", "userdbprivs", array(
                        'db'   => $db_name,
                        'user' => $user_name
                    ));
    
    the api work, but doesn't return the priviledge, it return this:
    Code:
    Array
    (
        [account_database - account_user] => SimpleXMLElement Object
            (
                [apiversion] => 2
                [data] => SimpleXMLElement Object
                    (
                    )
    
                [event] => SimpleXMLElement Object
                    (
                        [result] => 1
                    )
    
                [func] => userdbprivs
                [module] => MysqlFE
            )
    )
    
    Can someone help me?
    Thanks.
     
  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 Elia,

    The issue you're probably facing has to do with a bug in the xmlapi PHP client class. Because the xmlapi parser is looking for 'user' concerning the cpanel account AND the function requires a parameter of 'user' concerning the database user, the xmlapi PHP client class version 1.0.5 would clobber them and only send one.

    If you get the latest version of the xmlapi class (v1.0.6, found here: http://sdk.cpanel.net/lib/xmlapi/php/cp_xmlapi_php_v1.0.6.tar.gz ) your issue will probably dissipate. We now send 'cpanel_xmlapi_user' to address the xmlapi parser's needs.

    The following works for me with v1.0.6
    Code:
    // authenticating as root on port 2087
    
    include("xmlapi.php");
    
    $ip = "10.1.1.1";
    $root_pass = "S3cretP4ss";
    
    $account['username'] = "elia";
    
    
    $args['db'] = 'elia_e1';
    $args['user'] = 'elia_eu1';
    
    $xmlapi = new xmlapi($ip);
    
    $xmlapi->password_auth("root",$root_pass);
    $xmlapi->set_port('2087');
    
    $xmlapi->set_output('xml');
    $xmlapi->set_debug(1);
    
    $xmlapi->api2_query($account['username'], "MysqlFE", "userdbprivs", $args );
    
    
    OR
    Code:
    // authenticating as user on port 2083
    
    include("xmlapi.php");
    
    $ip = "10.1.1.1";
    
    
    $account['username'] = "elia";
    $account['password'] = '3ll4Secret';
    
    $args['db'] = 'elia_e1';
    $args['user'] = 'elia_eu1';
    
    $xmlapi = new xmlapi($ip);
    
    $xmlapi->password_auth($account['username'], $account['password']);
    $xmlapi->set_port('2083');
    
    $xmlapi->set_output('xml');
    $xmlapi->set_debug(1);
    
    $xmlapi->api2_query($account['username'], "MysqlFE", "userdbprivs", $args );
    
    Both give the same result:
    Code:
    DATA: db=elia_e1&user=elia_eu1&cpanel_xmlapi_user=elia&cpanel_xmlapi_module=MysqlFE&cpanel_xmlapi_func=userdbprivs&cpanel_xmlapi_apiversion=2
    
    RESPONSE:
       <cpanelresult>
        <apiversion>2</apiversion>
        <data>
          <ALTER>1</ALTER>
          <CREATE>1</CREATE>
          <DELETE>1</DELETE>
          <DROP>1</DROP>
          <SELECT>1</SELECT>
        </data>
        <event>
          <result>1</result>
        </event>
        <func>userdbprivs</func>
        <module>MysqlFE</module>
        <postevent>
          <result>1</result>
        </postevent>
        <preevent>
          <result>1</result>
        </preevent>
      </cpanelresult>
    
    Regards,
    -DavidN
     
  3. elia

    elia Registered

    Joined:
    Aug 13, 2010
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    1
    Thank you very much DavidN, now it works.
     
Loading...

Share This Page