Search code examples
apisoapzimbra

getting a list of aliases by domain from a zimbra server via soap admin api


I've been reading through the admin api reference documents, but I can't seem to find a way to list aliases already created for the domain.

There is, of course, the addAccountAlias command:

<AddAccountAliasRequest id="{value-of-zimbra-id}" alias="{alias}" />

And the removeAccountAlias command:

<RemoveAccountAliasRequest [id="{value-of-zimbra-id}"] alias="..." />

But I don't see a method to retrieve aliases for a domain. getAllAccounts and getAllDistributionLists don't return them.

Any help on this would be greatly appreciated.

This is the api documentation I'm referencing: Zimbra SOAP Api Reference


Solution

  • I've found the solution, the aliases for any given account are found in an attribute of the account called "zimbraMailAlias" in the GetAccount/GetAllAccounts response.

    <soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope"><soap:Header><context xmlns="urn:zimbra"><change token="2499"/></context></soap:Header><soap:Body><GetAllAccountsResponse xmlns="urn:zimbraAdmin">
    <account id="343058d1-0b31-4aad-8cc5-1bd819a597a5" name="someone@somewhere.com">
    ...
    <a n="zimbraMailAlias">alias1@somewhere.com</a>
    <a n="zimbraMailAlias">alias2@somewhere.com</a>
    ...
    </account></GetAllAccountsResponse></soap:Body></soap:Envelope>