use of com.zimbra.cs.ldap.ZSearchResultEntry 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;
}
use of com.zimbra.cs.ldap.ZSearchResultEntry in project zm-mailbox by Zimbra.
the class LdapProvisioning method getAddressListByQuery.
private List<AddressListInfo> getAddressListByQuery(String base, ZLdapFilter filter, boolean activeOnly, boolean getDN) throws ServiceException {
List<AddressListInfo> result = new ArrayList<AddressListInfo>();
try {
ZSearchResultEnumeration ne = helper.searchDir(base, filter, ZSearchControls.SEARCH_CTLS_SUBTREE(), null, LdapServerType.REPLICA);
while (ne.hasMore()) {
ZSearchResultEntry sr = ne.next();
if (getDN) {
AddressListInfo adl = new AddressListInfo(sr.getDN());
result.add(adl);
} else {
ZAttributes attrs = sr.getAttributes();
if (attrs != null) {
boolean active = Boolean.parseBoolean(attrs.getAttrString(Provisioning.A_zimbraIsAddressListActive));
boolean addToRes = activeOnly ? active : Boolean.TRUE;
if (addToRes) {
AddressListInfo adl = new AddressListInfo(attrs.getAttrString(Provisioning.A_zimbraId), attrs.getAttrString(Provisioning.A_uid), attrs.getAttrString(Provisioning.A_description));
if (!activeOnly) {
adl.setActive(active);
adl.setGalFilter(attrs.getAttrString(Provisioning.A_zimbraAddressListGalFilter));
adl.setLdapFilter(attrs.getAttrString(Provisioning.A_zimbraAddressListLdapFilter));
}
result.add(adl);
}
}
}
}
ne.close();
} catch (ServiceException e) {
throw ServiceException.FAILURE("unable to lookup address lists 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 listAllZimlets.
@Override
public List<Zimlet> listAllZimlets() throws ServiceException {
List<Zimlet> result = new ArrayList<Zimlet>();
try {
ZSearchResultEnumeration ne = helper.searchDir(mDIT.zimletBaseDN(), filterFactory.allZimlets(), ZSearchControls.SEARCH_CTLS_SUBTREE());
while (ne.hasMore()) {
ZSearchResultEntry sr = ne.next();
result.add(new LdapZimlet(sr.getDN(), sr.getAttributes(), this));
}
ne.close();
} catch (ServiceException e) {
throw ServiceException.FAILURE("unable to list all zimlets", e);
}
Collections.sort(result);
return result;
}
use of com.zimbra.cs.ldap.ZSearchResultEntry 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;
}
use of com.zimbra.cs.ldap.ZSearchResultEntry in project zm-mailbox by Zimbra.
the class LdapProvisioning method getDistributionListByQuery.
private DistributionList getDistributionListByQuery(String base, ZLdapFilter filter, ZLdapContext initZlc, boolean basicAttrsOnly) throws ServiceException {
String[] returnAttrs = basicAttrsOnly ? BASIC_DL_ATTRS : null;
DistributionList dl = null;
try {
ZSearchControls searchControls = ZSearchControls.createSearchControls(ZSearchScope.SEARCH_SCOPE_SUBTREE, ZSearchControls.SIZE_UNLIMITED, returnAttrs);
ZSearchResultEnumeration ne = helper.searchDir(base, filter, searchControls, initZlc, LdapServerType.REPLICA);
if (ne.hasMore()) {
ZSearchResultEntry sr = ne.next();
dl = makeDistributionList(sr.getDN(), sr.getAttributes(), basicAttrsOnly);
List<String> objectclass = sr.getAttributes().getMultiAttrStringAsList(Provisioning.A_objectClass, CheckBinary.NOCHECK);
if (dl != null && objectclass != null && objectclass.contains(AttributeClass.OC_zimbraHabGroup)) {
dl.setHABGroup(Boolean.TRUE);
}
}
ne.close();
} catch (ServiceException e) {
throw ServiceException.FAILURE("unable to lookup distribution list via query: " + filter.toFilterString() + " message: " + e.getMessage(), e);
}
return dl;
}
Aggregations