Search in sources :

Example 21 with ZSearchResultEnumeration

use of com.zimbra.cs.ldap.ZSearchResultEnumeration in project zm-mailbox by Zimbra.

the class LdapProvisioning method getAllUCServices.

@Override
public List<UCService> getAllUCServices() throws ServiceException {
    List<UCService> result = new ArrayList<UCService>();
    ZLdapFilter filter = filterFactory.allUCServices();
    try {
        ZSearchResultEnumeration ne = helper.searchDir(mDIT.ucServiceBaseDN(), filter, ZSearchControls.SEARCH_CTLS_SUBTREE());
        while (ne.hasMore()) {
            ZSearchResultEntry sr = ne.next();
            LdapUCService s = new LdapUCService(sr.getDN(), sr.getAttributes(), this);
            result.add(s);
        }
        ne.close();
    } catch (ServiceException e) {
        throw ServiceException.FAILURE("unable to list all servers", e);
    }
    if (result.size() > 0) {
        ucServiceCache.put(result, true);
    }
    Collections.sort(result);
    return result;
}
Also used : ZLdapFilter(com.zimbra.cs.ldap.ZLdapFilter) LdapUCService(com.zimbra.cs.account.ldap.entry.LdapUCService) UCService(com.zimbra.cs.account.UCService) 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) LdapUCService(com.zimbra.cs.account.ldap.entry.LdapUCService) ArrayList(java.util.ArrayList) ZSearchResultEntry(com.zimbra.cs.ldap.ZSearchResultEntry)

Example 22 with ZSearchResultEnumeration

use of com.zimbra.cs.ldap.ZSearchResultEnumeration in project zm-mailbox by Zimbra.

the class LdapProvisioning method getSignaturesByQuery.

private List<Signature> getSignaturesByQuery(Account acct, LdapEntry entry, ZLdapFilter filter, ZLdapContext initZlc, List<Signature> result) throws ServiceException {
    if (result == null) {
        result = new ArrayList<Signature>();
    }
    try {
        String base = entry.getDN();
        ZSearchResultEnumeration ne = helper.searchDir(base, filter, ZSearchControls.SEARCH_CTLS_SUBTREE(), initZlc, LdapServerType.REPLICA);
        while (ne.hasMore()) {
            ZSearchResultEntry sr = ne.next();
            result.add(new LdapSignature(acct, sr.getDN(), sr.getAttributes(), this));
        }
        ne.close();
    } catch (ServiceException e) {
        throw ServiceException.FAILURE("unable to lookup signature via query: " + filter.toFilterString() + " message: " + e.getMessage(), e);
    }
    return result;
}
Also used : LdapSignature(com.zimbra.cs.account.ldap.entry.LdapSignature) AccountServiceException(com.zimbra.cs.account.AccountServiceException) AuthFailedServiceException(com.zimbra.cs.account.AccountServiceException.AuthFailedServiceException) ServiceException(com.zimbra.common.service.ServiceException) Signature(com.zimbra.cs.account.Signature) LdapSignature(com.zimbra.cs.account.ldap.entry.LdapSignature) ZSearchResultEnumeration(com.zimbra.cs.ldap.ZSearchResultEnumeration) ZSearchResultEntry(com.zimbra.cs.ldap.ZSearchResultEntry)

Example 23 with ZSearchResultEnumeration

use of com.zimbra.cs.ldap.ZSearchResultEnumeration in project zm-mailbox by Zimbra.

the class LdapProvisioning method domainDnExists.

private boolean domainDnExists(ZLdapContext zlc, String dn) throws ServiceException {
    try {
        ZSearchResultEnumeration ne = helper.searchDir(dn, filterFactory.domainLabel(), ZSearchControls.SEARCH_CTLS_SUBTREE(), zlc, LdapServerType.MASTER);
        boolean result = ne.hasMore();
        ne.close();
        return result;
    } catch (ServiceException e) {
        // or should we throw?  TODO
        return false;
    }
}
Also used : 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)

Example 24 with ZSearchResultEnumeration

use of com.zimbra.cs.ldap.ZSearchResultEnumeration in project zm-mailbox by Zimbra.

the class LdapProvisioning method getMimeTypesByQuery.

@Override
public List<MimeTypeInfo> getMimeTypesByQuery(String mimeType) throws ServiceException {
    List<MimeTypeInfo> mimeTypes = new ArrayList<MimeTypeInfo>();
    try {
        ZSearchResultEnumeration ne = helper.searchDir(mDIT.mimeBaseDN(), filterFactory.mimeEntryByMimeType(mimeType), ZSearchControls.SEARCH_CTLS_SUBTREE());
        while (ne.hasMore()) {
            ZSearchResultEntry sr = ne.next();
            mimeTypes.add(new LdapMimeType(sr, this));
        }
        ne.close();
    } catch (ServiceException e) {
        throw ServiceException.FAILURE("unable to get mime types for " + mimeType, e);
    }
    return mimeTypes;
}
Also used : LdapMimeType(com.zimbra.cs.account.ldap.entry.LdapMimeType) 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) ArrayList(java.util.ArrayList) MimeTypeInfo(com.zimbra.cs.mime.MimeTypeInfo) ZSearchResultEntry(com.zimbra.cs.ldap.ZSearchResultEntry)

Example 25 with ZSearchResultEnumeration

use of com.zimbra.cs.ldap.ZSearchResultEnumeration in project zm-mailbox by Zimbra.

the class LdapProvisioning method getAllMimeTypesByQuery.

@Override
public List<MimeTypeInfo> getAllMimeTypesByQuery() throws ServiceException {
    List<MimeTypeInfo> mimeTypes = new ArrayList<MimeTypeInfo>();
    try {
        ZSearchResultEnumeration ne = helper.searchDir(mDIT.mimeBaseDN(), filterFactory.allMimeEntries(), ZSearchControls.SEARCH_CTLS_SUBTREE());
        while (ne.hasMore()) {
            ZSearchResultEntry sr = ne.next();
            mimeTypes.add(new LdapMimeType(sr, this));
        }
        ne.close();
    } catch (ServiceException e) {
        throw ServiceException.FAILURE("unable to get mime types", e);
    }
    return mimeTypes;
}
Also used : LdapMimeType(com.zimbra.cs.account.ldap.entry.LdapMimeType) 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) ArrayList(java.util.ArrayList) MimeTypeInfo(com.zimbra.cs.mime.MimeTypeInfo) ZSearchResultEntry(com.zimbra.cs.ldap.ZSearchResultEntry)

Aggregations

ZSearchResultEnumeration (com.zimbra.cs.ldap.ZSearchResultEnumeration)27 ZSearchResultEntry (com.zimbra.cs.ldap.ZSearchResultEntry)25 ServiceException (com.zimbra.common.service.ServiceException)15 AccountServiceException (com.zimbra.cs.account.AccountServiceException)14 AuthFailedServiceException (com.zimbra.cs.account.AccountServiceException.AuthFailedServiceException)14 ArrayList (java.util.ArrayList)14 ZLdapFilter (com.zimbra.cs.ldap.ZLdapFilter)11 ZSearchControls (com.zimbra.cs.ldap.ZSearchControls)11 ZLdapContext (com.zimbra.cs.ldap.ZLdapContext)4 LdapSizeLimitExceededException (com.zimbra.cs.ldap.LdapException.LdapSizeLimitExceededException)3 Account (com.zimbra.cs.account.Account)2 Cos (com.zimbra.cs.account.Cos)2 GuestAccount (com.zimbra.cs.account.GuestAccount)2 LdapDIT (com.zimbra.cs.account.ldap.LdapDIT)2 LdapAccount (com.zimbra.cs.account.ldap.entry.LdapAccount)2 LdapCos (com.zimbra.cs.account.ldap.entry.LdapCos)2 LdapMimeType (com.zimbra.cs.account.ldap.entry.LdapMimeType)2 MimeTypeInfo (com.zimbra.cs.mime.MimeTypeInfo)2 AlwaysOnCluster (com.zimbra.cs.account.AlwaysOnCluster)1 DataSource (com.zimbra.cs.account.DataSource)1