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.

Changing main ftp password through api

Discussion in 'cPanel Developers' started by Irritum, Feb 22, 2011.

  1. Irritum

    Irritum Member

    Joined:
    Feb 7, 2011
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    1
    Hello, i've faced the problem. When i want to change user's main ftp account (same as cPanelUser name), the api1 function for changing it doesn't work. I see, that there's xml-api/passwd function, which can change cPanel users password, but it writes, that it changes other system passwords (ftp, mysql, email). What i wanted to ask, what passwords does it change? Does it change all ftp passwords, or just main (does it really change email and mysql passwords?)

    Thank you in advance
     
  2. crazyaboutlinux

    crazyaboutlinux Well-Known Member

    Joined:
    Nov 3, 2007
    Messages:
    938
    Likes Received:
    0
    Trophy Points:
    16
    from where are you trying to change password from user's cPanel or from WHM (password modification option) ???
     
  3. Irritum

    Irritum Member

    Joined:
    Feb 7, 2011
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    1
    I'm using xml-api function and connecting trhough my root whm account (i have trial version of cPanel)
     
  4. crazyaboutlinux

    crazyaboutlinux Well-Known Member

    Joined:
    Nov 3, 2007
    Messages:
    938
    Likes Received:
    0
    Trophy Points:
    16
    if your are trying to change from root The following service passwords will be changed: system , ftp , mail , mySQL.

    if you do not wish to change mgSQL then uncheck this option Allow MySQL password change.

    and system, ftp, mail these are default options
     
  5. Irritum

    Irritum Member

    Joined:
    Feb 7, 2011
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    1
    Yah, but which passwords will it change? Lets say i create a cPanel user on domain newuser.com and then he creates addon newaddon.com (which automatically creates a ftp user newaddon@newuser.com). so does this xml-api function changes newaddon's password too?
     
  6. Irritum

    Irritum Member

    Joined:
    Feb 7, 2011
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    1
    I really need to know that
     
  7. 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 Irritum,

    If you want to change a select FTP user's password, I'd suggest using the API2 Ftp::passwd function. You can call it via XML-API.

    Scenario:
    1) your cpuser account 'dave' which controls 'mydomain.tld'
    2) 'dave' has an ftp user named "unique" in addition to his primary ftp user named "dave"
    3) "unique"'s actual ftp username is 'unique@mydomain.tld', while his primary ftp username is 'dave@mydomain.tld'
    4) you which to alter the password for 'unique' to "S3cr3t"

    The query string would be something like this
    Code:
    https://$server:2087/xml-api/cpanel
    DATA: user=unique%40mydomain.tld&pass=S3cr3t&cpanel_xmlapi_user=dave&cpanel_xmlapi_module=Ftp&cpanel_xmlapi_func=passwd&cpanel_xmlapi_apiversion=2
    
    If you're using our XML-API PHP class, the code would be similar to this
    PHP:
    include("xmlapi.php");

    $ip "1.1.1.1";
    $root_pass "r00tS3cr3t";

    $xmlapi = new xmlapi($ip);
    $xmlapi->password_auth("root",$root_pass);

    //$xmlapi->set_debug(1);
    $args = array(
        
    'user' => 'unique@mydomain.tld',
        
    'pass' => 'S3cr3t',
    );
    $xmlapi->api2_query('dave','Ftp','passwd',$args);
    That said, you cannot selectively change the password for the primary ftp login, aka 'dave@mydomain.tld' in our example above. This is not something that we currently support in cPanel. If you need this functionality, I suggest you open (or comment on an already existent) feature request in the Feature Request forum

    --
    And yes, the native XML-API change password function will change the primary ftp username credential. Like I mentioned earlier, cPanel currently synchronizes the ftp and cPanel logins credentials...they are coupled. Invoking this function will change: cPanel, ftp (primary user only), mail (primary user only), FrontPage(if installed), MySQL (unless optionally told not to), and PostgreSQL (if installed)


    Regards,
    -DavidN
     
Loading...

Share This Page