Search in sources :

Example 1 with GalSearchConfig

use of com.zimbra.cs.gal.GalSearchConfig in project zm-mailbox by Zimbra.

the class LdapGalSearch method doGalSearch.

private static void doGalSearch(GalSearchParams params) throws ServiceException {
    ZLdapContext zlc = null;
    try {
        GalSearchConfig cfg = params.getConfig();
        GalSearchConfig.GalType galType = params.getConfig().getGalType();
        if (galType == GalSearchConfig.GalType.zimbra) {
            zlc = LdapClient.getContext(LdapUsage.fromGalOp(params.getOp()));
        } else {
            ExternalLdapConfig ldapConfig = new ExternalLdapConfig(cfg.getUrl(), cfg.getStartTlsEnabled(), cfg.getAuthMech(), cfg.getBindDn(), cfg.getBindPassword(), cfg.getRules().getBinaryLdapAttrs(), "external GAL");
            zlc = LdapClient.getExternalContext(ldapConfig, LdapUsage.fromGalOp(params.getOp()));
        }
        String fetchEntryByDn = params.getSearchEntryByDn();
        if (fetchEntryByDn == null) {
            SearchGalResult sgr = params.getResult();
            if (sgr != null && GalOp.sync.equals(params.getOp())) {
                sgr.setLdapTimeStamp(params.getLdapTimeStamp());
                sgr.setLdapMatchCount(params.getLdapMatchCount());
                sgr.setHadMore(params.ldapHasMore());
                sgr.setMaxLdapTimeStamp(params.getMaxLdapTimeStamp());
            }
            if (params.isExpandQuery()) {
                searchGal(zlc, galType, cfg.getPageSize(), cfg.getSearchBase(), params.generateLdapQuery(), params.getLimit(), cfg.getRules(), params.getSyncToken(), params.getResult(), params.getOp());
            } else {
                searchGal(zlc, galType, cfg.getPageSize(), cfg.getSearchBase(), params.getQuery(), params.getLimit(), cfg.getRules(), params.getSyncToken(), params.getResult(), params.getOp());
            }
        } else {
            getGalEntryByDn(zlc, galType, fetchEntryByDn, cfg.getRules(), params.getResult());
        }
    } finally {
        LdapClient.closeContext(zlc);
    }
}
Also used : ZLdapContext(com.zimbra.cs.ldap.ZLdapContext) ExternalLdapConfig(com.zimbra.cs.ldap.LdapServerConfig.ExternalLdapConfig) GalSearchConfig(com.zimbra.cs.gal.GalSearchConfig) SearchGalResult(com.zimbra.cs.account.Provisioning.SearchGalResult)

Aggregations

SearchGalResult (com.zimbra.cs.account.Provisioning.SearchGalResult)1 GalSearchConfig (com.zimbra.cs.gal.GalSearchConfig)1 ExternalLdapConfig (com.zimbra.cs.ldap.LdapServerConfig.ExternalLdapConfig)1 ZLdapContext (com.zimbra.cs.ldap.ZLdapContext)1