Search in sources :

Example 1 with AddressList

use of com.zimbra.cs.account.AddressList in project zm-mailbox by Zimbra.

the class LdapProvisioning method getAddressList.

/**
 * @param id id of the address list
 * @return AddressList object
 * @throws ServiceException if an error occurs while querying LDAP.
 */
@Override
public AddressList getAddressList(String zimbraId) throws ServiceException {
    AddressList list = null;
    try {
        ZimbraLog.ldap.info("Called addresslist");
        String[] returnAttrs = { "objectClass", Provisioning.A_uid, Provisioning.A_zimbraId, Provisioning.A_zimbraAddressListGalFilter, Provisioning.A_description, Provisioning.A_zimbraIsAddressListActive, Provisioning.A_zimbraAddressListLdapFilter };
        ZSearchControls searchControls = ZSearchControls.createSearchControls(ZSearchScope.SEARCH_SCOPE_SUBTREE, ZSearchControls.SIZE_UNLIMITED, returnAttrs);
        ZSearchResultEnumeration ne = helper.searchDir(mDIT.mailBranchBaseDN(), filterFactory.addressListById(zimbraId), searchControls, null, LdapServerType.MASTER);
        if (ne.hasMore()) {
            ZSearchResultEntry sr = ne.next();
            String dn = sr.getDN();
            ZimbraLog.ldap.debug("Got address list: %s with attributes : %s", dn, sr.getAttributes());
            Map<String, Object> attrs = sr.getAttributes().getAttrs();
            String name = (String) attrs.get(Provisioning.A_displayName);
            list = new AddressList(dn, name, zimbraId, attrs, null, this);
        }
        ne.close();
    } catch (ServiceException e) {
        throw ServiceException.FAILURE(String.format("Unable to fetch address list '%s'", zimbraId), e);
    }
    return list;
}
Also used : ZSearchControls(com.zimbra.cs.ldap.ZSearchControls) AccountServiceException(com.zimbra.cs.account.AccountServiceException) AuthFailedServiceException(com.zimbra.cs.account.AccountServiceException.AuthFailedServiceException) ServiceException(com.zimbra.common.service.ServiceException) ZSearchResultEnumeration(com.zimbra.cs.ldap.ZSearchResultEnumeration) AddressList(com.zimbra.cs.account.AddressList) ZSearchResultEntry(com.zimbra.cs.ldap.ZSearchResultEntry)

Aggregations

ServiceException (com.zimbra.common.service.ServiceException)1 AccountServiceException (com.zimbra.cs.account.AccountServiceException)1 AuthFailedServiceException (com.zimbra.cs.account.AccountServiceException.AuthFailedServiceException)1 AddressList (com.zimbra.cs.account.AddressList)1 ZSearchControls (com.zimbra.cs.ldap.ZSearchControls)1 ZSearchResultEntry (com.zimbra.cs.ldap.ZSearchResultEntry)1 ZSearchResultEnumeration (com.zimbra.cs.ldap.ZSearchResultEnumeration)1