use of com.zimbra.cs.ldap.ZSearchResultEntry 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.ZSearchResultEntry 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.ZSearchResultEntry in project zm-mailbox by Zimbra.
the class LdapProvisioning method getDataSourcesByQuery.
private List<DataSource> getDataSourcesByQuery(LdapEntry entry, ZLdapFilter filter, ZLdapContext initZlc) throws ServiceException {
List<DataSource> result = new ArrayList<DataSource>();
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 LdapDataSource((Account) entry, sr.getDN(), sr.getAttributes(), this));
}
ne.close();
} catch (ServiceException e) {
throw ServiceException.FAILURE("unable to lookup data source via query: " + filter.toFilterString() + " message: " + e.getMessage(), e);
}
return result;
}
use of com.zimbra.cs.ldap.ZSearchResultEntry in project zm-mailbox by Zimbra.
the class LdapProvisioning method getGroupByQuery.
private Group getGroupByQuery(ZLdapFilter filter, ZLdapContext initZlc, boolean basicAttrsOnly, boolean loadFromMaster) throws ServiceException {
try {
String[] returnAttrs = basicAttrsOnly ? BASIC_GROUP_ATTRS : null;
ZSearchResultEntry sr = helper.searchForEntry(mDIT.mailBranchBaseDN(), filter, initZlc, loadFromMaster, returnAttrs);
if (sr != null) {
ZAttributes attrs = sr.getAttributes();
List<String> objectclass = attrs.getMultiAttrStringAsList(Provisioning.A_objectClass, CheckBinary.NOCHECK);
Group grp = null;
if (objectclass.contains(AttributeClass.OC_zimbraDistributionList)) {
grp = makeDistributionList(sr.getDN(), attrs, basicAttrsOnly);
} else if (objectclass.contains(AttributeClass.OC_zimbraGroup)) {
grp = makeDynamicGroup(initZlc, sr.getDN(), attrs);
}
if (grp != null && objectclass != null && objectclass.contains(AttributeClass.OC_zimbraHabGroup)) {
grp.setHABGroup(Boolean.TRUE);
}
return grp;
}
} catch (LdapMultipleEntriesMatchedException e) {
throw AccountServiceException.MULTIPLE_ENTRIES_MATCHED("getGroupByQuery", e);
} catch (ServiceException e) {
throw ServiceException.FAILURE("unable to lookup group via query: " + filter.toFilterString() + " message:" + e.getMessage(), e);
}
return null;
}
use of com.zimbra.cs.ldap.ZSearchResultEntry in project zm-mailbox by Zimbra.
the class LdapProvisioning method getIdentitiesByQuery.
private List<Identity> getIdentitiesByQuery(LdapEntry entry, ZLdapFilter filter, ZLdapContext initZlc) throws ServiceException {
List<Identity> result = new ArrayList<Identity>();
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 LdapIdentity((Account) entry, sr.getDN(), sr.getAttributes(), this));
}
ne.close();
} catch (ServiceException e) {
throw ServiceException.FAILURE("unable to lookup identity via query: " + filter.toFilterString() + " message: " + e.getMessage(), e);
}
return result;
}
Aggregations