use of com.zimbra.cs.ldap.ZLdapFilter in project zm-mailbox by Zimbra.
the class LdapProvisioning method getAllAlwaysOnClusters.
@Override
public List<AlwaysOnCluster> getAllAlwaysOnClusters() throws ServiceException {
List<AlwaysOnCluster> result = new ArrayList<AlwaysOnCluster>();
ZLdapFilter filter = filterFactory.allAlwaysOnClusters();
try {
ZSearchResultEnumeration ne = helper.searchDir(mDIT.alwaysOnClusterBaseDN(), filter, ZSearchControls.SEARCH_CTLS_SUBTREE());
while (ne.hasMore()) {
ZSearchResultEntry sr = ne.next();
LdapAlwaysOnCluster c = new LdapAlwaysOnCluster(sr.getDN(), sr.getAttributes(), null, this);
result.add(c);
}
ne.close();
} catch (ServiceException e) {
throw ServiceException.FAILURE("unable to list all alwaysOnClusters", e);
}
if (result.size() > 0)
alwaysOnClusterCache.put(result, true);
Collections.sort(result);
return result;
}
use of com.zimbra.cs.ldap.ZLdapFilter in project zm-mailbox by Zimbra.
the class LdapProvisioning method searchDynamicGroupInternalMembers.
private void searchDynamicGroupInternalMembers(ZLdapContext zlc, String dynGroupId, SearchLdapVisitor visitor) throws ServiceException {
String base = mDIT.mailBranchBaseDN();
ZLdapFilter filter = filterFactory.accountByMemberOf(dynGroupId);
SearchLdapOptions searchOptions = new SearchLdapOptions(base, filter, new String[] { A_zimbraMailDeliveryAddress, Provisioning.A_zimbraMemberOf }, SearchLdapOptions.SIZE_UNLIMITED, null, ZSearchScope.SEARCH_SCOPE_SUBTREE, visitor);
zlc.searchPaged(searchOptions);
}
use of com.zimbra.cs.ldap.ZLdapFilter in project zm-mailbox by Zimbra.
the class LdapProvisioning method getAllServers.
@Override
public List<Server> getAllServers(String service) throws ServiceException {
List<Server> result = new ArrayList<Server>();
ZLdapFilter filter;
if (service != null) {
filter = filterFactory.serverByService(service);
} else {
filter = filterFactory.allServers();
}
try {
Map<String, Object> serverDefaults = getConfig().getServerDefaults();
ZSearchResultEnumeration ne = helper.searchDir(mDIT.serverBaseDN(), filter, ZSearchControls.SEARCH_CTLS_SUBTREE());
while (ne.hasMore()) {
ZSearchResultEntry sr = ne.next();
LdapServer s = new LdapServer(sr.getDN(), sr.getAttributes(), serverDefaults, this);
result.add(s);
}
ne.close();
} catch (ServiceException e) {
throw ServiceException.FAILURE("unable to list all servers", e);
}
if (result.size() > 0)
serverCache.put(result, true);
Collections.sort(result);
return result;
}
use of com.zimbra.cs.ldap.ZLdapFilter in project zm-mailbox by Zimbra.
the class LdapDynamicGroup method updateGroupMembershipForCustomDynamicGroups.
public static GroupMembership updateGroupMembershipForCustomDynamicGroups(LdapProvisioning prov, GroupMembership membership, Account acct, Domain domain, boolean adminGroupsOnly) throws ServiceException {
String acctDN = prov.getDNforAccount(acct, null, false);
if (acctDN == null) {
return membership;
}
ZLdapFilter filter = ZLdapFilterFactory.getInstance().allDynamicGroups();
ZLdapContext zlcCompare = null;
try {
zlcCompare = LdapClient.getContext(LdapServerType.get(false), LdapUsage.COMPARE);
BySearchResultEntrySearcher searcher = new BySearchResultEntrySearcher(prov, (ZLdapContext) null, domain, BASIC_ATTRS, new GroupMembershipUpdator(prov, zlcCompare, acctDN, membership, adminGroupsOnly, true, false));
searcher.doSearch(filter, DYNAMIC_GROUPS_TYPE);
} finally {
LdapClient.closeContext(zlcCompare);
}
return membership;
}
use of com.zimbra.cs.ldap.ZLdapFilter in project zm-mailbox by Zimbra.
the class LdapDynamicGroup method updateGroupMembershipForDynamicGroups.
public static GroupMembership updateGroupMembershipForDynamicGroups(LdapProvisioning prov, GroupMembership membership, Account acct, Collection<String> ids, boolean adminGroupsOnly, boolean customGroupsOnly, boolean nonCustomGroupsOnly) throws ServiceException {
if (ids.size() == 0) {
return membership;
}
String acctDN = prov.getDNforAccount(acct, null, false);
if (acctDN == null) {
return membership;
}
ZLdapFilter filter = ZLdapFilterFactory.getInstance().dynamicGroupByIds(ids.toArray(new String[0]));
ZLdapContext zlcCompare = null;
try {
zlcCompare = LdapClient.getContext(LdapServerType.get(false), LdapUsage.COMPARE);
BySearchResultEntrySearcher searcher = new BySearchResultEntrySearcher(prov, (ZLdapContext) null, (Domain) null, BASIC_ATTRS, new GroupMembershipUpdator(prov, zlcCompare, acctDN, membership, adminGroupsOnly, customGroupsOnly, nonCustomGroupsOnly));
searcher.doSearch(filter, DYNAMIC_GROUPS_TYPE);
} finally {
LdapClient.closeContext(zlcCompare);
}
return membership;
}
Aggregations