Closed cecco closed 8 years ago
Hi Francesco, For deleting account, you need a user zimbra id. You can get it by getAccount method from api. For example:
$api = \Zimbra\Admin\AdminFactory::instance('https:/xx.xx.xx.xx:7071/service/admin/soap');
$api->auth('admin@domain', 'password');
$account = new \Zimbra\Struct\AccountSelector(\Zimbra\Enum\AccountBy::NAME(), 'user@domain');
$accountInfo = $api->getAccount($account);
$api->deleteAccount($accountInfo->id);
Thank you for your reply. but i got errors if use your code:
PHP message: PHP Catchable fatal error: Argument 3 passed to Zimbra\Admin\Request\GetAccount::__construct() must be of the type array, null given, called in /usr/share/nginx/html/vendor/zimbra-api/soap-api/src/Zimbra/Admin/Base.php on line 1433 and defined in /usr/share/nginx/html/vendor/zimbra-api/soap-api/src/Zimbra/Admin/Request/GetAccount.php on line 38
If I change the second-last line to
$accountInfo = $api->getAccount($account,null,array());
I get: `PHP message: PHP Fatal error: Uncaught exception 'RuntimeException' with message 'Property id is not defined.' in /usr/share/nginx/html/vendor/zimbra-api/soap-api/src/Zimbra/Soap/Response.php:63 Stack trace:
thrown in /usr/share/nginx/html/vendor/zimbra-api/soap-api/src/Zimbra/Soap/Response.php on line 63` Thank You
Hi Francesco, All of api methods return an object corresponding to response xml of zimbra soap api. So you can reference zimbra soap api document at https://files.zimbra.com/docs/soap_api/8.6.0/api-reference/index.html
This is example code i was tested successfully:
$api = \Zimbra\Admin\AdminFactory::instance('https:/xx.xx.xx.xx:7071/service/admin/soap');
$api->auth('admin@domain', 'password');
$account = new \Zimbra\Struct\AccountSelector(\Zimbra\Enum\AccountBy::NAME(), 'user@domain');
$response = $api->getAccount($account, null, array());
$api->deleteAccount($response->account->id);
Hi, I'm trying to delete an account (I have successfully created one).
I'm using:
I got in zimbra mailbox.log:
I understand deleteAccount need a user id, but how can i get it from api?
Thank you, your job is great!
Francesco