Hi Nesan,
There's not a 'clean' API call for what you need. However, there's a unique way that you can get user variables, like the primary domain, for remote calls.
Remote calls use the XML-API. There's a special API1 module called 'print' that will allow you access to the cPanel user's variables. When making the XML-API call you will want to pass the following values:
1) your "module" key will have a value 'print'
2) do not pass the "function" key
3) your argument for the 'print' module will be '$CPDATA{\'DOMAIN\'}'
So, if you were to manually construct an XML-API URL, it would look like this
Code:
https://$server:2083/xml-api/cpanel?cpanel_xmlapi_module=print&cpanel_xmlapi_apiversion=1&arg-0=%24CPDATA%7B%27DOMAIN%27%7D
If you happen to be using the PHP XML-API client class you script would look something like this
PHP Code:
<?php
include "xmlapi.php";
$ip = '10.1.1.1';
$user = 'my_cPanel_username';
$pass = 'cpanel_password';
$xmlapi = new xmlapi($ip);
$xmlapi->password_auth($user, $pass);
$xmlapi->set_port(2083);
#$xmlapi->set_debug(1);
$xmlapi->api1_query($user, 'print','', array('$CPDATA{\'DOMAIN\'}'));
?>
Regards,
-DavidN
FYI: 'DNS' should also be a valid CPDATA key for extracting the primary domain