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

Obtain User Data for a Domain — domainuserdata

This function lets you obtain user data for a specific domain.

Calling Functions

Using the XML API

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

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

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

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

  • 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 domainuserdata function takes the following required variable as input:

  • domain (string) — Name of the domain for which you wish to obtain user data.
    • Example: example.com

Output

The output of this function corresponds directly to the domain's VirtualHost entry in the file httpd.conf. As such, output may differ depending on each domain's configuration. However, most of the parameters below will be defined for most domains.

  • domainuserdata — Root-level XML tag for the output of the domainuserdata function.
    • result — Container for information about the domainuserdata function call.
      • status (boolean) — Whether the call was successful.
        • 1 — success.
        • 0 — failure.
      • statusmsg (string) — Status or error message about the domainuserdata function call.
    • userdata — Container for the user data for the domain.
      • documentroot (string) — Location of the domain's public_html folder. This directory holds the site's web-accessible files.
      • group — Group to which the domain has been assigned, if applicable.
      • hascgi (boolean) — Whether the domain is able to process CGI scripts.
        • 1 — yes.
        • 0 — no.
      • homedir (string) — Home directory that holds the domain's files, including those not accessible via the web.
      • ip (string) — IP at which the domain resides.
      • owner — Username of the reseller or host who owns the account.
      • port (string) — Port the Apache web server uses to access the domain.
      • scriptalias — Container for information about the domain's use of the Apache web server's ScriptAlias directive.
        • path (string) — Actual location of scripts processed by Apache's CGI script handler.
        • url (string) — Alias URL that, when accessed, redirects to the path URL.
      • serveradmin (string) — Email address of the account owner (not the server administrator).
      • serveralias (string) — Any alias that exists for the domain name.
      • servername (string) — Main domain name for the account.
      • user (string) — Username of the domain owner.

Examples

XML API

Calling the following function in WebHost Manager:

https://example.net:2087/xml-api/domainuserdata?domain=example.com

will produce output similar to:

<domainuserdata>
     <result>
          <status>1</status>
          <statusmsg>Obtained userdata.</statusmsg>
     </result>
     <userdata>
          <documentroot>/home/example/public_html</documentroot>
          <group>example</group>
          <hascgi>1</hascgi>
          <homedir>/home/example</homedir>
          <ip>127.0.0.1</ip>
          <owner>john</owner>
          <port>80</port>
          <scriptalias>
               <path>/home/example/public_html/cgi-bin</path>
               <url>/cgi-bin/</url>
          </scriptalias>
          <scriptalias>
               <path>/home/example/public_html/cgi-bin/</path>
               <url>/cgi-bin/</url>
          </scriptalias>
          <serveradmin>webmaster@example.com</serveradmin>
          <serveralias>
          www.example.com
          </serveralias>
          <servername>example.com</servername>
          <user>jane</user>
     </userdata>
</domainuserdata>

JSON API

Calling the following function in WebHost Manager:

https://example.net:2087/json-api/domainuserdata?domain=example.com

will produce output similar to:

{
   "result":[
      {
         "status":1,
         "statusmsg":"Obtained userdata."
      }
   ],
   "userdata":{
      "group":"example",
      "documentroot":"/home/example/public_html",
      "serveradmin":"webmaster@example.com",
      "servername":"example.com",
      "ip":"127.0.0.1",
      "scriptalias":[
         {
            "path":"/home/example/public_html/cgi-bin",
            "url":"/cgi-bin/"
         },
         {
            "path":"/home/example/public_html/cgi-bin/",
            "url":"/cgi-bin/"
         }
      ],
      "serveralias":"www.example.com",
      "homedir":"/home/example",
      "port":"80",
      "hascgi":"1",
      "user":"jane",
      "owner":"john"
   }
}

Topic revision: r3 - 21 Dec 2009 - 17:31:08 - Main.JustinSchaefer