Search in sources :

Example 71 with ZLdapFilter

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;
}
Also used : ZLdapFilter(com.zimbra.cs.ldap.ZLdapFilter) ServiceException(com.zimbra.common.service.ServiceException) ArrayList(java.util.ArrayList) Domain(com.zimbra.cs.account.Domain)

Example 72 with ZLdapFilter

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();
}
Also used : ZLdapFilter(com.zimbra.cs.ldap.ZLdapFilter) LdapDIT(com.zimbra.cs.account.ldap.LdapDIT) SearchLdapVisitor(com.zimbra.cs.ldap.SearchLdapOptions.SearchLdapVisitor)

Example 73 with ZLdapFilter

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;
}
Also used : ZLdapFilter(com.zimbra.cs.ldap.ZLdapFilter)

Example 74 with ZLdapFilter

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);
}
Also used : ZLdapFilter(com.zimbra.cs.ldap.ZLdapFilter) ZLdapFilterFactory(com.zimbra.cs.ldap.ZLdapFilterFactory)

Example 75 with ZLdapFilter

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();
}
Also used : ZLdapFilter(com.zimbra.cs.ldap.ZLdapFilter)

Aggregations

ZLdapFilter (com.zimbra.cs.ldap.ZLdapFilter)123 ZSearchResultEntry (com.zimbra.cs.ldap.ZSearchResultEntry)15 ZSearchResultEnumeration (com.zimbra.cs.ldap.ZSearchResultEnumeration)13 ZLdapContext (com.zimbra.cs.ldap.ZLdapContext)10 ZSearchControls (com.zimbra.cs.ldap.ZSearchControls)10 ServiceException (com.zimbra.common.service.ServiceException)9 AccountServiceException (com.zimbra.cs.account.AccountServiceException)8 AuthFailedServiceException (com.zimbra.cs.account.AccountServiceException.AuthFailedServiceException)8 ArrayList (java.util.ArrayList)8 Server (com.zimbra.cs.account.Server)7 LdapDIT (com.zimbra.cs.account.ldap.LdapDIT)7 Account (com.zimbra.cs.account.Account)6 LdapSizeLimitExceededException (com.zimbra.cs.ldap.LdapException.LdapSizeLimitExceededException)6 NamedEntry (com.zimbra.cs.account.NamedEntry)5 SearchAccountsOptions (com.zimbra.cs.account.SearchAccountsOptions)5 BySearchResultEntrySearcher (com.zimbra.cs.account.ldap.BySearchResultEntrySearcher)5 SearchLdapOptions (com.zimbra.cs.ldap.SearchLdapOptions)5 ProvTest (com.zimbra.qa.unittest.prov.ProvTest)5 LDAPException (com.unboundid.ldap.sdk.LDAPException)3 SearchRequest (com.unboundid.ldap.sdk.SearchRequest)3