use of com.zimbra.cs.ldap.ZLdapFilter in project zm-mailbox by Zimbra.
the class CollectAllEffectiveRights method searchSubDomains.
private List<Domain> searchSubDomains(Domain domain) throws ServiceException {
List<Domain> subDomains = new ArrayList<Domain>();
String base = mProv.getDIT().domainNameToDN(domain.getName());
ZLdapFilter filter = ZLdapFilterFactory.getInstance().allDomains();
String[] returnAttrs = new String[] { Provisioning.A_zimbraId };
SearchSubDomainVisitor visitor = new SearchSubDomainVisitor();
mProv.searchLdapOnMaster(base, filter, returnAttrs, visitor);
List<String> zimbraIds = visitor.getResults();
for (String zimbraId : zimbraIds) {
if (zimbraId.equalsIgnoreCase(domain.getId())) {
// the search returns the domain itself too, skip it
continue;
}
try {
Domain subDomain = (Domain) TargetType.lookupTarget(mProv, TargetType.domain, TargetBy.id, zimbraId);
subDomains.add(subDomain);
} catch (ServiceException e) {
ZimbraLog.acl.warn("canot find domain by id " + zimbraId, e);
}
}
return subDomains;
}
use of com.zimbra.cs.ldap.ZLdapFilter in project zm-mailbox by Zimbra.
the class CollectAllEffectiveRights method getAllCalendarResources.
private Set<String> getAllCalendarResources() throws ServiceException {
LdapDIT ldapDIT = mProv.getDIT();
String base = ldapDIT.mailBranchBaseDN();
ZLdapFilter filter = ZLdapFilterFactory.getInstance().allCalendarResources();
// hack, see LDAPDIT.dnToEmail, for now we get naming rdn for both default and possible custom DIT
String[] returnAttrs = new String[] { Provisioning.A_cn, Provisioning.A_uid };
Visitor visitor = new Visitor(mProv);
mProv.searchLdapOnMaster(base, filter, returnAttrs, visitor);
return visitor.getResult();
}
use of com.zimbra.cs.ldap.ZLdapFilter in project zm-mailbox by Zimbra.
the class SearchDirectoryOptions method equals.
@Override
public boolean equals(Object o) {
if (!(o instanceof SearchDirectoryOptions)) {
return false;
}
if (o == this) {
return true;
}
SearchDirectoryOptions other = (SearchDirectoryOptions) o;
if (onMaster != other.getOnMaster()) {
return false;
}
if (useConnPool != other.getUseConnPool()) {
return false;
}
if (maxResults != other.getMaxResults()) {
return false;
}
if (domain != null) {
Domain otherDomain = other.getDomain();
if (otherDomain == null) {
return false;
}
if (!domain.getId().equals(otherDomain.getId())) {
return false;
}
} else {
if (other.getDomain() != null) {
return false;
}
}
if (filter != null) {
ZLdapFilter otherFilter = other.getFilter();
if (otherFilter == null) {
return false;
} else {
if (!filter.toFilterString().equals(otherFilter.toFilterString())) {
return false;
}
}
} else {
if (other.getFilter() != null) {
return false;
}
}
if (filterId != other.getFilterId()) {
return false;
}
if (filterStr != null) {
String otherFilterStr = other.getFilterString();
if (otherFilterStr == null) {
return false;
} else {
if (!filterStr.equals(otherFilterStr)) {
return false;
}
}
} else {
if (other.getFilterString() != null) {
return false;
}
}
if (getTypesAsFlags() != other.getTypesAsFlags()) {
return false;
}
if (returnAttrs != null) {
String[] otherReturnAttrs = other.getReturnAttrs();
if (otherReturnAttrs == null) {
return false;
} else {
Set<String> attrsSet = Sets.newHashSet(Arrays.asList(returnAttrs));
Set<String> otherAttrsSet = Sets.newHashSet(Arrays.asList(otherReturnAttrs));
if (!attrsSet.equals(otherAttrsSet)) {
return false;
}
}
} else {
if (other.getReturnAttrs() != null) {
return false;
}
}
if (makeObjOpt != other.getMakeObjectOpt()) {
return false;
}
if (sortOpt != other.getSortOpt()) {
return false;
}
if (sortAttr != null) {
String otherSortAttr = other.getSortAttr();
if (otherSortAttr == null) {
return false;
} else {
if (!sortAttr.equals(otherSortAttr)) {
return false;
}
}
} else {
if (other.getSortAttr() != null) {
return false;
}
}
if (convertIDNToAscii != other.getConvertIDNToAscii()) {
return false;
}
return true;
}
use of com.zimbra.cs.ldap.ZLdapFilter in project zm-mailbox by Zimbra.
the class BUG_68831 method upgradeDLs.
private void upgradeDLs(ZLdapContext zlc) throws ServiceException {
String[] bases = prov.getDIT().getSearchBases(Provisioning.SD_DISTRIBUTION_LIST_FLAG);
ZLdapFilterFactory filterFactory = ZLdapFilterFactory.getInstance();
ZLdapFilter homeServerPresent = filterFactory.fromFilterString(FilterId.LDAP_UPGRADE, filterFactory.presenceFilter(ATTR_NAME));
ZLdapFilter homeServerNotPresent = filterFactory.negate(homeServerPresent);
String query = filterFactory.andWith(filterFactory.allDistributionLists(), homeServerNotPresent).toFilterString();
upgrade(zlc, bases, query);
}
use of com.zimbra.cs.ldap.ZLdapFilter in project zm-mailbox by Zimbra.
the class LdapProvisioning method getNumAccountsOnServer.
private long getNumAccountsOnServer(Server server) throws ServiceException {
ZLdapFilter filter = filterFactory.accountsHomedOnServer(server.getServiceHostname());
String base = mDIT.mailBranchBaseDN();
String[] attrs = new String[] { Provisioning.A_zimbraId };
CountingVisitor visitor = new CountingVisitor();
searchLdapOnMaster(base, filter, attrs, visitor);
return visitor.getNumAccts();
}
Aggregations