Page 1 of 1

Zimbra API error

Posted: Tue May 16, 2017 2:31 pm
by pisavi
I'm using https://github.com/zimbra-api/zimbra-api as a php api wrapper, following these rules https://files.zimbra.com/docs/soap_api/ ... index.html.
Some of the call works (getAccountInfo, getDomainInfo) but others don't, like GetAllAccounts.

Here's that part of code:

Code: Select all

<?php
$mUsername = '*****@*******.com';
$mPassword = '**************************';
$api = \Zimbra\Admin\AdminFactory::instance('https://********:7071/service/admin/soap');
$logauth = $api->auth($mUsername, $mPassword);

$mDomain = '*******';

$domain = new \Zimbra\Admin\Struct\DomainSelector(\Zimbra\Enum\DomainBy::VIRTUAL_HOSTNAME(), $mDomain);
$server = new \Zimbra\Admin\Struct\ServerSelector(\Zimbra\Enum\ServerBy::SERVICE_HOSTNAME(), $mDomain);

$myVar= $api->getallaccounts($domain, $server);

Even though $domain and $server are 100% correct, i get this error:

Fatal error: Uncaught exception 'GuzzleHttp\Exception\ServerException' with message 'Server error: `POST https://*************:7071/service/admin/soap` resulted in a `500 Server Error` response: <soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope ... r><context xmlns="urn:zimbra"><change tok (truncated...) ' in /var/www/ZimbraApi/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php:113 Stack trace: #0 /var/www/ZimbraApi/vendor/guzzlehttp/guzzle/src/Middleware.php(65): GuzzleHttp\Exception\RequestException::create(Object(GuzzleHttp\Psr7\Request), Object(GuzzleHttp\Psr7\Response)) #1 /var/www/ZimbraApi/vendor/guzzlehttp/promises/src/Promise.php(203): GuzzleHttp\Middleware::GuzzleHttp\{closure}(Object(GuzzleHttp\Psr7\Response)) #2 /var/www/ZimbraApi/vendor/guzzlehttp/promises/src/Promise.php(156): GuzzleHttp\Promise\Promise::callHandler(1, Object(GuzzleHttp\Psr7\Response), Array) #3 /var/www/ZimbraApi/vendor/guzzlehttp/promises/src/TaskQueue.php(47): GuzzleHttp\Promise\Promise::GuzzleHttp\Pro in /var/www/ZimbraApi/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php on line 113

What can I do?

Re: Zimbra API error

Posted: Wed May 17, 2017 2:46 pm
by ajcody
There's a chance that the code wasn't updated to use "zmprov -l gaa" vs "zmprov gaa". I forget which version of ZCS is was, but there was a change where -l was required for gaa to work.

Re: Zimbra API error

Posted: Wed May 17, 2017 2:58 pm
by pisavi
ajcody wrote:There's a chance that the code wasn't updated to use "zmprov -l gaa" vs "zmprov gaa". I forget which version of ZCS is was, but there was a change where -l was required for gaa to work.
Hi, thanks for your answer.
Unfortunately, searching trough the files, I can see that the wrapper doesn't use zmprov or gaa.
Am I doing something wrong?

Re: Zimbra API error

Posted: Sun May 28, 2017 3:59 pm
by iomarmochtar
you may change max search result configuration if you have more than 5000 account.

run this command in (each) mailbox server, for instance allow max to 10000

su - zimbra
zmlocalconfig -e zimbra_directory_max_search_result=10000
zmcontrol restart

the better way to fetch list of user is through ldap, that's why zmprov for fetching all user (getAllAccounts or gaa) require -l .

Re: Zimbra API error

Posted: Mon May 29, 2017 7:48 am
by pisavi
iomarmochtar wrote:you may change max search result configuration if you have more than 5000 account.

run this command in (each) mailbox server, for instance allow max to 10000

su - zimbra
zmlocalconfig -e zimbra_directory_max_search_result=10000
zmcontrol restart

the better way to fetch list of user is through ldap, that's why zmprov for fetching all user (getAllAccounts or gaa) require -l .
Thanks for your help, but I am not even close to 5000 accounts so that might not be the problem

Re: Zimbra API error

Posted: Mon May 29, 2017 8:25 am
by iomarmochtar
For testing purpose you can try my own zimbra API library.

https://gist.github.com/iomarmochtar/b9 ... 3133730ba7


just install python-requests module then modify in the bottom of file as your environment then use gaa method for fetch all users.

eg:

Code: Select all

	zmprov = ZMPROV(
	 	username='admin',
	 	password='passwd123',
	 	soapurl='https://192.168.1.30:7071/service/admin/soap',
	 	# isdebug=True
	)

	pprint( zmprov.gaa()  )
execute the script

python ozsoap.py

if the script is running well then you may trace the problem within PHP library that you use.

Re: Zimbra API error

Posted: Wed May 31, 2017 11:56 am
by pisavi
iomarmochtar wrote:For testing purpose you can try my own zimbra API library.

https://gist.github.com/iomarmochtar/b9 ... 3133730ba7


just install python-requests module then modify in the bottom of file as your environment then use gaa method for fetch all users.

eg:

Code: Select all

	zmprov = ZMPROV(
	 	username='admin',
	 	password='passwd123',
	 	soapurl='https://192.168.1.30:7071/service/admin/soap',
	 	# isdebug=True
	)

	pprint( zmprov.gaa()  )
execute the script

python ozsoap.py

if the script is running well then you may trace the problem within PHP library that you use.
Thanks you I am using your API library now, works perfectly.