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);
}
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);
}
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;
}
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;
}
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;
}
Aggregations