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 Bugs...

Discussion in 'cPanel Developers' started by darmoran, Feb 22, 2010.

  1. darmoran

    darmoran Registered

    Joined:
    Jan 8, 2010
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    1
    Hey Guys,

    I've been mucking around creating some API based scripts for WHM, and I've come across a few things which are making me crazy as they don't seem to work as they should.

    using /xml-api/modifyacct?user=<user>&domain=<newdomain> it appears to modify the accounts domain however, it's been keeping the previous domain within the DNS entries, and it also comes back within the <domains> tags

    Eg.
    Code:
    <domains>domain1.com</domains>
    <domains>domain2.com</domains>
    <domains>domain3.com</domains>
    
    Is this standard function of the API, or a random bug I am seeing here?
     
  2. emduck

    emduck Member

    Joined:
    May 30, 2005
    Messages:
    6
    Likes Received:
    0
    Trophy Points:
    1
    I concur: old domain names linger in /etc/userdomains

    Hi,
    I found this post and it matches my experience.
    It makes it frustrating to test the 'modifyacct' XML API function.

    I'm hoping this is an easy bug to fix and we might see it in an upcoming release.

    I've replicated the issue very simply:

    1) Create a new account, with domain abc.com

    2) Modify the account, giving it domain name xyz.com
    Run this shell command, and you get a result
    when you should not:
    $ grep abc.com /etc/userdomains

    3) Attempt to change the domain name BACK to abc.com
    WHM won't let you, instead will give this error:

    Sorry, the domain name cannot be changed because it is owned by another user.

    Any help on this appreciated!

    Emily
     
  3. 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 Emily,

    I was unable to reproduce the problem with the following code (that uses our XML-API php client class)

    Code:
    include("xmlapi.php");
    
    $ip = "192.168.1.1";
    $root_pass = "supersecret";
    
    $xmlapi = new xmlapi($ip);
    $xmlapi->password_auth("root",$root_pass);
    $xmlapi->set_debug(1);
    
    $acct = array( 'username' => "someuser", 'password' => "pass123", 'domain' => "thisdomain.com");
    
    $xmlapi->removeacct($acct['username']); //verifies account does not exist
    
    $xmlapi->createacct($acct);
    
    //generate request: /xml-api/modifyacct?domain=theredomain.com&user=someuser
    $xmlapi->modifyacct($acct['username'], array('domain'=>'theredomain.com'));
    
    //generate request: /xml-api/modifyacct?domain=thisdomain.com&user=someuser
    $xmlapi->modifyacct($acct['username'], array('domain'=>'thisdomain.com'));
    
    In each call I got the expected return. Specifically in the last two calls:
    Code:
    --snip---
    
     <messages>thisdomain.com =&gt; deleted from davesbox. 
    </messages>
        <messages>Domain name changed</messages>
        <newcfg>
          <cpuser>
            <BWLIMIT>unlimited</BWLIMIT>
            <CONTACTEMAIL></CONTACTEMAIL>
            <CONTACTEMAIL2></CONTACTEMAIL2>
            <DEMO>0</DEMO>
            <DOMAIN>theredomain.com</DOMAIN>
    
    --snip--
    
    <messages>theredomain.com =&gt; deleted from davesbox. 
    </messages>
        <messages>Domain name changed</messages>
        <newcfg>
          <cpuser>
            <BWLIMIT>unlimited</BWLIMIT>
            <CONTACTEMAIL></CONTACTEMAIL>
            <CONTACTEMAIL2></CONTACTEMAIL2>
            <DEMO>0</DEMO>
            <DOMAIN>thisdomain.com</DOMAIN>
    
    --snip--
    
    Those calls specify that the old domain is being dropped, and later in the account summary, the variable 'domain' is itemized as the new one.

    I also ran it step by step and checked both /etc/userdomains and /etc/domainusers and they were correct all the way.

    What version/build of cPanel are you running?

    If you're still having problems, I'd consider submitting a ticket to cPanel Support. Feel free to reference this post.

    Regards,
    -David
     
  4. emduck

    emduck Member

    Joined:
    May 30, 2005
    Messages:
    6
    Likes Received:
    0
    Trophy Points:
    1
    Thanks

    David,

    Thanks for the thorough reply.

    My server is on these stable versions:
    cPanel 11.25.0-S44718
    WHM 11.25.0 - X 3.9

    I will definitely submit this to cPanel support, as I can replicate it via WHM. (Simpler I think, than replicating via PHP code--but either way, I see the issue in /etc/userdomains.)

    Thanks so much!
    Emily
     
Loading...

Share This Page