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);
}
}
Aggregations