Software Development Kit

cPanel & WHM's API [+] cPanel & WHM's API [-]


Modules and Plugins [+] Modules and Plugins [-]


cPanel & WHM Hooks [+] cPanel & WHM Hooks [-]


cPAddons (Site Software) [+] cPAddons (Site Software) [-]


System Administration [+] System Administration [-]


Developer Software [+] Developer Software [-]


Back to All Documentation

Change an Account's Password — passwd

This function changes the password of a domain owner (cPanel) or reseller (WHM) account.

Calling Functions

Using the XML API

To use the XML API to perform the passwd function from within your custom script:

  • Append the /xml-api/passwd function call name, plus the required variables (see below), to a URL which includes the address of your server.

  • For example, on a server whose hostname is example.com, you would include the following string in your script: https://example.com:2087/xml-api/passwd

  • You need to be logged in with the proper permissions in order to call a function. See our document about Authenticating API Function Calls for more information about authenticating APIs from within a script.

  • You can also perform the function by entering the string in your web browser's address bar. This may be useful for testing the function call and viewing its output.

Using the JSON API

To use the JSON API to perform the passwd function from within your custom script:

  • Append the /json-api/passwd function call name, plus the required variables (see below), to a URL which includes the address of your server.

  • For example, on a server whose hostname is example.com, you would include the following string in your script: https://example.com:2087/json-api/passwd

  • You need to be logged in with the proper permissions in order to call a function. See our document about Authenticating API Function Calls for more information about authenticating APIs from within a script.

  • You can also perform the function by entering the string in your web browser's address bar. This may be useful for testing the function call and viewing its output.

Variables

Input

The passwd function takes the following variables as input.

These variables are required:

  • user (string) — Name of the user whose password should be changed.
  • pass (string) — New password for the user.

This variable is optional:

  • db_pass_update (boolean) — Change the MySQL password
    • 1 (default value) — Change the MySQL password.
    • 0 — Do not change the MySQL password.

Output

  • passwd — Root-level tag for the output of the passwd function.
    • passwd — Result node.
      • rawout — Raw message output.
      • services — List of services for which the password has been updated.
        • app — Service for which the password was updated. Should include the following:
          • system
          • ftp
          • mail
          • mysql
      • status — Whether or not the operation completed successfully.
        • 1 — yes.
        • 0 — no.
      • statusmsg — Details of the success or failure.

Examples

XML API

Calling the following function:

https://example.com:2087/xml-api/passwd?user=bob&pass=r3allyc0pml3xp@ss!234

in WebHost Manager will produce output similar to:

<passwd>
        <passwd>
                <rawout>        
                 Changing password for bob 
                 Password for bob has been changed 
                 Updating ftp passwords for bob 
                 Ftp password files updated. 
                 Ftp vhost passwords synced
                </rawout>
                 <services>
                      <app>system</app>
                 </services>
                 <services>
                      <app>ftp</app>
                 </services>
                 <services>
                      <app>mail</app>
                 </services>
                 <services>
                       <app>mySQL</app>
                 </services>
                <status>1</status>
                <statusmsg>Password changed for user bob</statusmsg>
        </passwd>
</passwd>

JSON API

Calling the following function:

https://example.com:2087/json-api/passwd?user=gus&pass=r3allyc0pml3xp@ss!234

in WebHost Manager will produce output similar to:

{
   "passwd":[
      {
         "status":1,
         "services":[
            {
               "app":"system"
            },
            {
               "app":"ftp"
            },
            {
               "app":"mail"
            },
            {
               "app":"mySQL"
            }
         ],
         "statusmsg":"Password changed for user gus",
         "rawout":"Changing password for gus\nPassword for gus has been changed\n
          Updating ftp passwords for gus\nFtp password files updated.\n
          Ftp vhost passwords synced\n"
      }
   ]
}

Topic revision: r8 - 10 Aug 2011 - 15:07:02 - MelanieSeibert