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

Suspend an Account — suspendacct

This function will allow you to prevent a cPanel user from accessing his or her account. Once an account is suspended, it can be un-suspended to allow a user to access the account again.

If you wish to permanently remove an account, you need to use the removeacct function.

Calling Functions

Using the XML API

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

  • Append the /xml-api/suspendacct 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/suspendacct

  • 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 suspendacct function from within your custom script:

  • Append the /json-api/suspendacct 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/suspendacct

  • 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 suspendacct function takes the following variables as input.

The following variable is required:

  • user — Name of the user to suspend.

The following variables are optional:

  • reason — Reason for suspension.
    • We recommend giving a reason for the account suspension to make managing suspended accounts easier.
  • disallowun — This value determines whether resellers are allowed to unsuspend the account. This parameter is only available in version 11.40+.
    • 1 — Resellers will be unable to unsuspend the account. Only root or root -enabled resellers will be able to unsuspend the reseller.
    • 0 — Resellers will be able to unsuspend the account.

Output

  • suspendacct — Root-level XML tag for the output of the suspendacct function.
    • result — Container for the results of the account suspension.
      • status (boolean) — Whether or not the operation succeeded.
        • 1 — yes.
        • 0 — no.
      • statusmsg (string) — Message(s) about the result of the operation.

Examples

XML API

Calling https://example.com:2087/xml-api/suspendacct?user=user123 in WebHost Manager will produce output similar to:

<suspendacct>
    <result>
        <status>1</status>
        <statusmsg>
            <script>if (self['clear_ui_status']) { clear_ui_status(); }</script>
            Changing Shell to /bin/false...Changing shell for user123.
            Warning: "/bin/false" is not listed in /etc/shells
            Shell changed.
            Done
            Locking Password...Locking password for user user123.
            passwd: Success
            Done
            Suspending mysql users
            Notification => user@example.net via EMAIL [level => 3]
            Using Quota v3 Support
            Suspended document root /home/cpanel1/public_html
            Using Quota v3 Support
            Suspending FTP accounts...
            Updating ftp passwords for user123
            Ftp password files updated.
            Ftp vhost passwords synced
            user123's account has been suspended
        </statusmsg>
    </result>
</suspendacct>

JSON API

Calling https://example.com:2087/json-api/suspendacct?user=user123 in WebHost Manager will produce output similar to:

{
   "result":[
      {
         "status":1,
         "statusmsg":"<script>if (self['clear_ui_status']) { clear_ui_status(); }</script>
\nChanging Shell to /bin/false...Changing shell for user123.\nWarning: \"/bin/false\" 
is not listed in /etc/shells\nShell changed.\nDone\nLocking Password...Locking 
password for user user123.\npasswd: Success\nDone\nSuspending mysql users\n
Notification => user@example.com via EMAIL [level => 3]\nUsing Quota v3 
Support\nSuspended document root /home/user123/public_html\nUsing Quota v3 
Support\nSuspending FTP accounts...\nUpdating ftp passwords for user123\nFtp 
password files updated.\nFtp vhost passwords synced\nuser123's account has 
been suspended\n"
      }
   ]
}

Topic revision: r7 - 10 Oct 2013 - 21:34:39 - Main.LaurenceSimon