Community Forums
Connect with us on LinkedIn
+ Reply to Thread
Results 1 to 3 of 3
  1. #1
    Registered User
    Join Date
    Aug 2010
    Posts
    3

    Default Api 2 MysqlFE userdbprivs problems

    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. #2
    Integration Developer cPanelDavidN's Avatar
    Join Date
    Dec 2009
    Location
    Houston, TX
    Posts
    525

    Default

    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..._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
    David Neimeyer
    Integration Developer

    sdk.cpanel.net
    APIs: XML-API API1 & API2
    Check Out: Developer Downloads Integration Blog
    Need Support? Support Ticket Developer Forum Feature Request

  3. #3
    Registered User
    Join Date
    Aug 2010
    Posts
    3

    Default

    Thank you very much DavidN, now it works.

Similar Threads & Tags
Similar threads

  1. Replies: 1
    Last Post: 06-04-2011, 09:52 AM
  2. MysqlFE::userdbprivs() syntax
    By lvt in forum cPanel Developers
    Replies: 13
    Last Post: 07-30-2010, 02:25 PM
  3. MysqlFE::userdbprivs() returning only 1
    By testpgm in forum cPanel Developers
    Replies: 0
    Last Post: 05-26-2010, 03:09 AM
  4. MysqlFE::listdbs modify output?
    By arcuturus1 in forum cPanel Developers
    Replies: 2
    Last Post: 11-24-2009, 08:17 PM
  5. Windoz VISTA and FTP, problems, problems, problems
    By jols in forum cPanel and WHM Discussions
    Replies: 0
    Last Post: 12-31-2007, 08:40 PM
Linkedin       Facebook       Twitter       RSS       Flickr       YouTube