Search in sources :

Example 61 with ZLdapFilter

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

the class TestLdapZLdapFilter method dataSourceByName.

@Test
public void dataSourceByName() throws Exception {
    String NAME = getTestName();
    String filter = LegacyLdapFilter.dataSourceByName(NAME);
    ZLdapFilter zLdapFilter = filterDactory.dataSourceByName(NAME);
    verify(FilterId.DATA_SOURCE_BY_NAME, filter, zLdapFilter);
}
Also used : ZLdapFilter(com.zimbra.cs.ldap.ZLdapFilter)

Example 62 with ZLdapFilter

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

the class TestLdapZLdapFilter method imComponentById.

@Test
public void imComponentById() throws Exception {
    String ID = genUUID();
    String filter = LegacyLdapFilter.imComponentById(ID);
    ZLdapFilter zLdapFilter = filterDactory.imComponentById(ID);
    verify(FilterId.XMPP_COMPONENT_BY_ZIMBRA_XMPP_COMPONENT_ID, filter, zLdapFilter);
}
Also used : ZLdapFilter(com.zimbra.cs.ldap.ZLdapFilter)

Example 63 with ZLdapFilter

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

the class DistributionList method getContainingDLs.

public static List<BasicInfo> getContainingDLs(LdapProvisioning prov, ZLdapContext zlc, List<BasicInfo> dls, boolean adminGroupsOnly, boolean directOnly) throws ServiceException {
    final int chunkSize = 500;
    List<String> addrs = Lists.newArrayList();
    for (BasicInfo dl : dls) {
        addrs.addAll(dl.getAllAddrsAsGroupMember());
    }
    int lastIndex = addrs.size() - 1;
    int start = 0;
    int end = (lastIndex < chunkSize) ? lastIndex : chunkSize - 1;
    List<BasicInfo> containingDLs = Lists.newArrayList();
    while (end <= lastIndex) {
        String[] chunk = addrs.subList(start, end + 1).toArray(new String[0]);
        ZLdapFilter filter = ZLdapFilterFactory.getInstance().distributionListsByMemberAddrs(chunk);
        ContainingDLUpdator dlUpdator = new ContainingDLUpdator(prov, adminGroupsOnly);
        BySearchResultEntrySearcher searcher = new BySearchResultEntrySearcher(prov, zlc, (Domain) null, BASIC_ATTRS, dlUpdator);
        searcher.doSearch(filter, DISTRIBUTION_LISTS);
        containingDLs.addAll(dlUpdator.getDistLists());
        if (end >= lastIndex) {
            break;
        }
        start += chunkSize;
        end += chunkSize;
        if (end > lastIndex) {
            end = lastIndex;
        }
    }
    return containingDLs;
}
Also used : ZLdapFilter(com.zimbra.cs.ldap.ZLdapFilter) BySearchResultEntrySearcher(com.zimbra.cs.account.ldap.BySearchResultEntrySearcher)

Example 64 with ZLdapFilter

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

the class LdapProvisioning method getAccountById.

private Account getAccountById(String zimbraId, ZLdapContext zlc, boolean loadFromMaster) throws ServiceException {
    if (zimbraId == null)
        return null;
    Account a = accountCache.getById(zimbraId);
    if (a == null) {
        ZLdapFilter filter = filterFactory.accountById(zimbraId);
        a = getAccountByQuery(mDIT.mailBranchBaseDN(), filter, zlc, loadFromMaster);
        // search again under the admin base if not found and admin base is not under mail base
        if (a == null && !mDIT.isUnder(mDIT.mailBranchBaseDN(), mDIT.adminBaseDN()))
            a = getAccountByQuery(mDIT.adminBaseDN(), filter, zlc, loadFromMaster);
        accountCache.put(a);
    }
    return a;
}
Also used : ZLdapFilter(com.zimbra.cs.ldap.ZLdapFilter) Account(com.zimbra.cs.account.Account) GuestAccount(com.zimbra.cs.account.GuestAccount) LdapAccount(com.zimbra.cs.account.ldap.entry.LdapAccount)

Example 65 with ZLdapFilter

use of com.zimbra.cs.ldap.ZLdapFilter 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)

Aggregations

ZLdapFilter (com.zimbra.cs.ldap.ZLdapFilter)123 ZSearchResultEntry (com.zimbra.cs.ldap.ZSearchResultEntry)15 ZSearchResultEnumeration (com.zimbra.cs.ldap.ZSearchResultEnumeration)13 ZLdapContext (com.zimbra.cs.ldap.ZLdapContext)10 ZSearchControls (com.zimbra.cs.ldap.ZSearchControls)10 ServiceException (com.zimbra.common.service.ServiceException)9 AccountServiceException (com.zimbra.cs.account.AccountServiceException)8 AuthFailedServiceException (com.zimbra.cs.account.AccountServiceException.AuthFailedServiceException)8 ArrayList (java.util.ArrayList)8 Server (com.zimbra.cs.account.Server)7 LdapDIT (com.zimbra.cs.account.ldap.LdapDIT)7 Account (com.zimbra.cs.account.Account)6 LdapSizeLimitExceededException (com.zimbra.cs.ldap.LdapException.LdapSizeLimitExceededException)6 NamedEntry (com.zimbra.cs.account.NamedEntry)5 SearchAccountsOptions (com.zimbra.cs.account.SearchAccountsOptions)5 BySearchResultEntrySearcher (com.zimbra.cs.account.ldap.BySearchResultEntrySearcher)5 SearchLdapOptions (com.zimbra.cs.ldap.SearchLdapOptions)5 ProvTest (com.zimbra.qa.unittest.prov.ProvTest)5 LDAPException (com.unboundid.ldap.sdk.LDAPException)3 SearchRequest (com.unboundid.ldap.sdk.SearchRequest)3