Author |
|
festusngor Newbie
Joined: 10 April 2018 Location: United Kingdom
Online Status: Offline Posts: 20
|
Posted: 11 April 2018 at 6:23am | IP Logged
|
|
|
What is ErrorCode 108? Can't seem to find it in the documentation. I was trying to Create and Update Server using Web API and it keeps coming up.
This is my Error log display for CreateServer and UpdateServer respectively:
[13:09:35.26][e70059c9] API: Mail::CreateServer
[13:09:35.32][e70059c9] Aurora\System\Exceptions\ApiException: ApiException in C:\Apache24\htdocs\Sandbox\webmail_php\system\Api.php:1261
Stack trace:
#0 C:\Apache24\htdocs\Sandbox\webmail_php\modules\Mail\Module.php(1066): Aurora\System\Api::checkUserRoleIsAtLeast(0)
#1 [internal function]: Aurora\Modules\Mail\Module->CreateServer('YMail', 'imap.mail.yahoo...', 993, true, 'smtp.mail.yahoo...', 465, true, '2', '*', NULL, NULL, NULL, '', '', 0)
#2 C:\Apache24\htdocs\Sandbox\webmail_php\system\Module\AbstractModule.php(873): call_user_func_array(Array, Array)
#3 C:\Apache24\htdocs\Sandbox\webmail_php\modules\Core\Module.php(531): Aurora\System\Module\AbstractModule->CallMethod('CreateServer', Array, true)
#4 [internal function]: Aurora\Modules\Core\Module->EntryApi()
#5 C:\Apache24\htdocs\Sandbox\webmail_php\system\Module\AbstractModule.php(619): call_user_func_array(Array, Array)
#6 C:\Apache24\htdocs\Sandbox\webmail_php\system\Module\Manager.php(689): Aurora\System\Module\AbstractModule->RunEntry('api')
#7 C:\Apache24\htdocs\Sandbox\webmail_php\system\Application.php(87): Aurora\System\Module\Manager->RunEntry('api')
#8 C:\Apache24\htdocs\Sandbox\webmail_php\index.php(21): Aurora\System\Application::Start()
#9 {main}
[13:22:10.07][7f571199] API: Mail::UpdateServer
[13:22:10.13][7f571199] Aurora\System\Exceptions\ApiException: ApiException in C:\Apache24\htdocs\Sandbox\webmail_php\system\Api.php:1261
Stack trace:
#0 C:\Apache24\htdocs\Sandbox\webmail_php\modules\Mail\Module.php(1168): Aurora\System\Api::checkUserRoleIsAtLeast(0)
#1 [internal function]: Aurora\Modules\Mail\Module->UpdateServer(4, 'GMail', 'imap.gmail.com', 993, true, 'smtp.gmail.com', 465, true, '2', '*', NULL, NULL, NULL, '', '', 0)
#2 C:\Apache24\htdocs\Sandbox\webmail_php\system\Module\AbstractModule.php(873): call_user_func_array(Array, Array)
#3 C:\Apache24\htdocs\Sandbox\webmail_php\modules\Core\Module.php(531): Aurora\System\Module\AbstractModule->CallMethod('UpdateServer', Array, true)
#4 [internal function]: Aurora\Modules\Core\Module->EntryApi()
#5 C:\Apache24\htdocs\Sandbox\webmail_php\system\Module\AbstractModule.php(619): call_user_func_array(Array, Array)
#6 C:\Apache24\htdocs\Sandbox\webmail_php\system\Module\Manager.php(689): Aurora\System\Module\AbstractModule->RunEntry('api')
#7 C:\Apache24\htdocs\Sandbox\webmail_php\system\Application.php(87): Aurora\System\Module\Manager->RunEntry('api')
#8 C:\Apache24\htdocs\Sandbox\webmail_php\index.php(21): Aurora\System\Application::Start()
#9 {main}
|
Back to Top |
|
|
Igor AfterLogic Support
Joined: 24 June 2008 Location: United States
Online Status: Offline Posts: 6104
|
Posted: 11 April 2018 at 6:42am | IP Logged
|
|
|
The error means Access Denied (see system/Notifications.php file for list of error codes, those within 101-115 apply), make sure you authenticate as admin prior to attempting to use those methods.
--
Regards,
Igor, Afterlogic Support
|
Back to Top |
|
|
festusngor Newbie
Joined: 10 April 2018 Location: United Kingdom
Online Status: Offline Posts: 20
|
Posted: 11 April 2018 at 6:57am | IP Logged
|
|
|
How do I authenticate as Admin?
|
Back to Top |
|
|
Igor AfterLogic Support
Joined: 24 June 2008 Location: United States
Online Status: Offline Posts: 6104
|
Posted: 11 April 2018 at 7:11am | IP Logged
|
|
|
It's done the same way you'd authenticate as user, just supply admin credentials - by default it's superadmin login, empty password.
--
Regards,
Igor, Afterlogic Support
|
Back to Top |
|
|
festusngor Newbie
Joined: 10 April 2018 Location: United Kingdom
Online Status: Offline Posts: 20
|
Posted: 11 April 2018 at 7:29am | IP Logged
|
|
|
Tried it as this:
'Parameters'=>'{"Login":"superadmin","Password":"","SignMe":TRUE}'
but its returning this even though there is no password set:
{"AuthenticatedUserId":0,"@Time":1.1214079856872559,"ErrorCode":4004,"ErrorMessage":"The username or password you entered is incorrect","Module":"Core"}
|
Back to Top |
|
|
Igor AfterLogic Support
Joined: 24 June 2008 Location: United States
Online Status: Offline Posts: 6104
|
Posted: 12 April 2018 at 2:12am | IP Logged
|
|
|
That line of the code looks good actually, can you please post the entire block of code which logs user in? Also, please recheck that you can log into admin interface with superadmin login and empty password.
--
Regards,
Igor, Afterlogic Support
|
Back to Top |
|
|
festusngor Newbie
Joined: 10 April 2018 Location: United Kingdom
Online Status: Offline Posts: 20
|
Posted: 12 April 2018 at 2:24am | IP Logged
|
|
|
This is it and I can log into admin interface with superadmin login and empty password
function emailApiAuthentication($apiMethod, $apiParams)
{
return CURL::POST(
EMAIL_API_URI,
[
'Module' => 'Core',
'Method' => $apiMethod,
'Parameters' => $apiParams,
],
[CURLOPT_SSL_VERIFYPEER => TRUE]
);
}
$authResponse = emailApiAuthentication('Login', '{"Login":"superadmin","Password":"","SignMe":TRUE}');
if ($authResponse && $authResponse->result) {
$emailAuthResponse = json_decode($authResponse->result);
// Fetch mail folders.
if (intval($emailAuthResponse->AuthenticatedUserId) > 0) {
$mailServers = [
"f etchEm ail" => emailApiRequest(
&n bsp;&n bsp; 'Mail',
&n bsp;&n bsp; 'GetServers',
&n bsp;&n bsp; NULL,
&n bsp;&n bsp; $emailAuthResponse->Result->AuthToken
),
];
// Set authenticated parameters for system-wide usage.
$_SESSION['emailApiParamAdmin'] = [
'e mailUs erAuthID' => intval($emailAuthResponse->AuthenticatedUserId),
'e mailUs erAuthAcct' => NULL,
'e mailUs erAuthToken' => $emailAuthResponse->Result->AuthToken,
];
} else {
throw new \Exception("{$emailAuthResponse->ErrorMessage}. Contact administrator");
}
} else {
throw new \Exception(($e->getMessage() ?? "Cannot connect to email server for login. Contact administrator"));
}
|
Back to Top |
|
|
Igor AfterLogic Support
Joined: 24 June 2008 Location: United States
Online Status: Offline Posts: 6104
|
Posted: 12 April 2018 at 3:23am | IP Logged
|
|
|
Thank you. It looks like you're using some external library to send requests via CURL, we've just tried that with PHP CURL functions as follows:
Code:
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,"http://local.test/?Api");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,
"Module=Core&Method=Login&Parameters={\"Login\":\"superadmin\",\"Password\":\"\",\"SignMe\":true}");
// receive server response ...
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$server_output = curl_exec ($ch);
curl_close ($ch);
var_dump($server_output); |
|
|
And it worked just fine for us. Can you try that and let us know if it works for you?
--
Regards,
Igor, Afterlogic Support
|
Back to Top |
|
|
festusngor Newbie
Joined: 10 April 2018 Location: United Kingdom
Online Status: Offline Posts: 20
|
Posted: 12 April 2018 at 5:09am | IP Logged
|
|
|
Worked for me too but I'm using the same CURL class for user authentication though and its working . Many thanks Igor
|
Back to Top |
|
|