spacechase0

Registered
Sep 5, 2010
4
0
51
I'm trying to create a MySQL user through the XML-API, and it says that it was made successfully, but whenever I check the cPanel, nothing shows up. It also says it was successful in adding the 'created' user to the database, but that doesn't show up, either.

I'm using the following url (for creating the user):
Code:
/xml-api/cpanel?user=******&cpanel_xmlapi_module=Mysql&cpanel_xmlapi_func=adduser&cpanel_xmlapi_apiversion=1&arg-0=commoninformationuser&arg-1=*********
And I get the this as a result:
Code:
<?xml version="1.0" ?>
<cpanelresult><module>Mysql</module><func>adduser</func><type>event</type><source>internal</source><apiversion>1</apiversion><data><result></result></data>  <event>
    <result>1</result>
  </event>
</cpanelresult>
I'm not really sure how to continue at the moment.... Any ideas about why it isn't working?
 

cPanelDavidN

Well-Known Member
Staff member
Dec 17, 2009
571
3
68
Houston, TX
cPanel Access Level
Root Administrator
Hi spacechase0,

API1 calls, unfortunately, don't typically provide much in the way of information in their response. Their "status" or "result" nodes are notorious for referencing the execution of the code path, and not the state of action that one has requested.

Do you get any messages in /usr/local/cpanel/logs/error_log?

If need be, you may wish to install the API Tracer, if your box is not in production (as the Tracer will log alot, including sensitive information).

Regards,
-DavidN
 

spacechase0

Registered
Sep 5, 2010
4
0
51
I don't see any '/usr/' folder in the root, and I can see other hidden files/folders there, so I'm guessing it's not that.... I probably should have mentioned I'm on a shared server.

I downloaded the API Tracer, but the Read Me file said that I needed to put some files in the '/usr/'.

Is there another of doing this?
 

cPanelDavidN

Well-Known Member
Staff member
Dec 17, 2009
571
3
68
Houston, TX
cPanel Access Level
Root Administrator
In order to install the API Tracer you'll need root access. And since you mentioned that you're on a shared server and that you don't have a /usr/ directory, I'd imagine your account is in an shell jail. This will make debug more difficult.

1) after you run the "adduser" API call, can you connect to MySQL on the command line with that user? You shell jail may not have access to the mysql CLI. If that is the case, I'd add a remote access entry for some IP address for a machine that you have a mysql CLI (or other MySQL client). If you can connect with the new user, then we have might have a bug. Otherwise, we need to figure out want about your API call is incorrect and adjust accordingly.

2) what version of cPanel is install on you server?

3) I'm curious, have you tried the "adddb" API call? Were you able to add a database (and it show up in the cPanel interface)? Or is it just the "adduser" API call that is failing?

-DavidN
 

spacechase0

Registered
Sep 5, 2010
4
0
51
1. I can't login with the created user, but it works fine with my cPanel user.

2. I couldn't find something that explicitly said the version, but the documentation link took me to the section for 11.26.9-RELEASE_48422.

3. Database creation works fine.
 

cPanelDavidN

Well-Known Member
Staff member
Dec 17, 2009
571
3
68
Houston, TX
cPanel Access Level
Root Administrator
I know it's kind of silly, but I need to ask:

The new database user that you're trying to create, how long is the name?

MySQL user names are limited to 16 characters. All cPanel created database users will have a prefix based the cPanel account name, which makes for even fewer characters to work with.*

example:
my cPanel account name: "dave"
my new database user name to be created "lildave"
API call with "arg-0=lildave" will create a database user 'dave_lildave' (total of 12 characters)

Additionally, the creation functions 'adddb' and 'adduser' want only the unique part of the name, if you send the full (prefix plus unique), it will likely fail. (depend on you cPanel version, if I remember correctly)

So...you will need to make sure that the name you provide is A) not prefixed and B) not too long.

If that isn't the case, then you may consider opening a support ticket. You're welcome to PM with the ticket number and I will help tech support expedite it.

Regards,
-DavidN

*the exception to this is cPanel 11.25.1/11.28 and higher, which has DB Mapping. It's possible for the WHM/cPanel administrator to turn prefixing off. This is great for utilizing the full character limit in MySQL usernames, but does offer it's only logistical drawbacks.
 

spacechase0

Registered
Sep 5, 2010
4
0
51
Originally, it's length was 17 characters (which would end up to 24). :P

I changed it to get the first nine characters of the domain name, and it works perfectly now!

Thank you!
 

MattDees

Well-Known Member
Apr 29, 2005
416
1
243
Houston, TX
cPanel Access Level
Root Administrator
I'm using the following url (for creating the user):
Code:
/xml-api/cpanel?user=******&cpanel_xmlapi_module=Mysql&cpanel_xmlapi_func=adduser&cpanel_xmlapi_apiversion=1&arg-0=commoninformationuser&arg-1=*********
I'm not really sure how to continue at the moment.... Any ideas about why it isn't working?

Your username is too long, mysql users in cpanel are limited to 9 characters.

This will be addressed in future versions of the product.

I am well aware of the issues with the Mysql module and we will be adding API2 versions of these calls in the future (that will give relevant feedback)