Search in sources :

Example 16 with LdapDomain

use of com.zimbra.cs.account.ldap.entry.LdapDomain in project zm-mailbox by Zimbra.

the class GalSearchConfig method loadZimbraConfig.

protected void loadZimbraConfig(Domain domain, GalOp op, GalSearchType stype) throws ServiceException {
    mRules = new LdapGalMapRules(domain, true);
    mOp = op;
    NamedFilter filterName = null;
    switch(op) {
        case sync:
            filterName = (stype == GalSearchType.all) ? NamedFilter.zimbraSync : (stype == GalSearchType.resource) ? NamedFilter.zimbraResourceSync : (stype == GalSearchType.group) ? NamedFilter.zimbraGroupSync : NamedFilter.zimbraAccountSync;
            break;
        case search:
            filterName = (stype == GalSearchType.all) ? NamedFilter.zimbraSearch : (stype == GalSearchType.resource) ? NamedFilter.zimbraResources : (stype == GalSearchType.group) ? NamedFilter.zimbraGroups : NamedFilter.zimbraAccounts;
            mTokenizeKey = domain.getAttr(Provisioning.A_zimbraGalTokenizeSearchKey, null);
            break;
        case autocomplete:
            filterName = (stype == GalSearchType.all) ? NamedFilter.zimbraAutoComplete : (stype == GalSearchType.resource) ? NamedFilter.zimbraResourceAutoComplete : (stype == GalSearchType.group) ? NamedFilter.zimbraGroupAutoComplete : NamedFilter.zimbraAccountAutoComplete;
            mTokenizeKey = domain.getAttr(Provisioning.A_zimbraGalTokenizeAutoCompleteKey, null);
            break;
    }
    String filter = null;
    if (filterName != null) {
        filter = GalSearchConfig.getFilterDef(filterName);
    }
    if (filter == null && op == GalOp.sync) {
        filter = GalFilter.DEFAULT_SYNC_FILTER;
    }
    mAuthMech = Provisioning.LDAP_AM_SIMPLE;
    if (filter == null) {
        filter = "";
    } else if (!filter.startsWith("(")) {
        filter = "(" + filter + ")";
    }
    String dnSubtreeMatchFilter = null;
    String searchBaseRaw = ZimbraGalSearchBase.getSearchBaseRaw(domain, op);
    if (ZimbraGalSearchBase.PredefinedSearchBase.DOMAIN.name().equals(searchBaseRaw)) {
        dnSubtreeMatchFilter = ((LdapDomain) domain).getDnSubtreeMatchFilter().toFilterString();
    }
    if (dnSubtreeMatchFilter == null) {
        dnSubtreeMatchFilter = "";
    }
    mFilter = "(&" + filter + "(!(zimbraHideInGal=TRUE))(!(zimbraIsSystemResource=TRUE))" + dnSubtreeMatchFilter + ")";
    mSearchBase = ZimbraGalSearchBase.getSearchBase(domain, op);
    mGalType = GalType.zimbra;
    mTimestampFormat = LdapDateUtil.ZIMBRA_LDAP_GENERALIZED_TIME_FORMAT_LEGACY;
    mPageSize = 1000;
}
Also used : LdapGalMapRules(com.zimbra.cs.account.ldap.LdapGalMapRules) LdapDomain(com.zimbra.cs.account.ldap.entry.LdapDomain) NamedFilter(com.zimbra.cs.gal.GalFilter.NamedFilter)

Aggregations

LdapDomain (com.zimbra.cs.account.ldap.entry.LdapDomain)16 Domain (com.zimbra.cs.account.Domain)12 Account (com.zimbra.cs.account.Account)4 ServiceException (com.zimbra.common.service.ServiceException)3 AccountServiceException (com.zimbra.cs.account.AccountServiceException)3 DynamicGroup (com.zimbra.cs.account.DynamicGroup)3 NamedEntry (com.zimbra.cs.account.NamedEntry)3 LdapException (com.zimbra.cs.ldap.LdapException)3 LdapEntryAlreadyExistException (com.zimbra.cs.ldap.LdapException.LdapEntryAlreadyExistException)3 ZLdapContext (com.zimbra.cs.ldap.ZLdapContext)3 AuthFailedServiceException (com.zimbra.cs.account.AccountServiceException.AuthFailedServiceException)2 DistributionList (com.zimbra.cs.account.DistributionList)2 Group (com.zimbra.cs.account.Group)2 SearchDirectoryOptions (com.zimbra.cs.account.SearchDirectoryOptions)2 ObjectType (com.zimbra.cs.account.SearchDirectoryOptions.ObjectType)2 CallbackContext (com.zimbra.cs.account.callback.CallbackContext)2 ZLdapFilter (com.zimbra.cs.ldap.ZLdapFilter)2 ZMutableEntry (com.zimbra.cs.ldap.ZMutableEntry)2 ProvTest (com.zimbra.qa.unittest.prov.ProvTest)2 Date (java.util.Date)2