use of com.zimbra.cs.gal.GalSearchParams in project zm-mailbox by Zimbra.
the class AutoCompleteGal method handle.
@Override
public Element handle(Element request, Map<String, Object> context) throws ServiceException {
ZimbraSoapContext zsc = getZimbraSoapContext(context);
String domainName = request.getAttribute(AdminConstants.A_DOMAIN);
Provisioning prov = Provisioning.getInstance();
Domain domain = prov.get(Key.DomainBy.name, domainName);
if (domain == null)
throw AccountServiceException.NO_SUCH_DOMAIN(domainName);
checkDomainRight(zsc, domain, Admin.R_accessGAL);
String name = request.getAttribute(AccountConstants.E_NAME);
int limit = (int) request.getAttributeLong(AdminConstants.A_LIMIT, 0);
String typeStr = request.getAttribute(AccountConstants.A_TYPE, GalSearchType.account.name());
GalSearchType type = GalSearchType.fromString(typeStr);
String galAcctId = request.getAttribute(AccountConstants.A_GAL_ACCOUNT_ID, null);
GalSearchParams params = new GalSearchParams(domain, zsc);
params.setType(type);
params.setRequest(request);
params.setQuery(name);
params.setLimit(limit);
params.setResponseName(AdminConstants.AUTO_COMPLETE_GAL_RESPONSE);
if (galAcctId != null)
params.setGalSyncAccount(Provisioning.getInstance().getAccountById(galAcctId));
params.setResultCallback(new SearchGal.AdminGalCallback(params));
GalSearchControl gal = new GalSearchControl(params);
gal.autocomplete();
return params.getResultCallback().getResponse();
}
use of com.zimbra.cs.gal.GalSearchParams in project zm-mailbox by Zimbra.
the class LdapProvisioning method autoCompleteGal.
@Override
public SearchGalResult autoCompleteGal(Domain domain, String query, GalSearchType type, int limit, GalContact.Visitor visitor) throws ServiceException {
SearchGalResult searchResult = SearchGalResult.newSearchGalResult(visitor);
GalSearchParams params = new GalSearchParams(domain, null);
params.setQuery(query);
params.setType(type);
params.setOp(GalOp.autocomplete);
params.setLimit(limit);
params.setGalResult(searchResult);
LdapOnlyGalSearchResultCallback callback = new LdapOnlyGalSearchResultCallback(params, visitor);
params.setResultCallback(callback);
GalSearchControl gal = new GalSearchControl(params);
gal.ldapSearch();
// Collections.sort(searchResult.getMatches()); sort?
return searchResult;
}
use of com.zimbra.cs.gal.GalSearchParams in project zm-mailbox by Zimbra.
the class LdapProvisioning method syncGal.
@Override
public SearchGalResult syncGal(Domain domain, String token, GalContact.Visitor visitor) throws ServiceException {
SearchGalResult searchResult = SearchGalResult.newSearchGalResult(visitor);
GalSearchParams params = new GalSearchParams(domain, null);
params.setQuery("");
params.setToken(token);
params.setType(GalSearchType.all);
params.setOp(GalOp.sync);
params.setFetchGroupMembers(true);
params.setNeedSMIMECerts(true);
params.setGalResult(searchResult);
LdapOnlyGalSearchResultCallback callback = new LdapOnlyGalSearchResultCallback(params, visitor);
params.setResultCallback(callback);
GalSearchControl gal = new GalSearchControl(params);
gal.ldapSearch();
return searchResult;
}
use of com.zimbra.cs.gal.GalSearchParams in project zm-mailbox by Zimbra.
the class SearchCalendarResources method searchGal.
private static Element searchGal(ZimbraSoapContext zsc, Account account, Element request) throws ServiceException {
Element name = request.getOptionalElement(AccountConstants.E_NAME);
EntrySearchFilter filter = GalExtraSearchFilter.parseSearchFilter(request);
GalSearchParams params = new GalSearchParams(account, zsc);
params.setQuery(name == null ? null : name.getText());
if (filter != null) {
params.setExtraQueryCallback(new CalendarResourceExtraQueryCallback(filter));
}
params.setType(GalSearchType.resource);
params.setRequest(request);
params.setResponseName(AccountConstants.SEARCH_CALENDAR_RESOURCES_RESPONSE);
// also note that mailbox search has a hard limit of 1000
if (request.getAttribute(MailConstants.A_QUERY_LIMIT, null) == null)
request.addAttribute(MailConstants.A_QUERY_LIMIT, 100);
// set limit for the LDAP search
// paging is not supported for LDAP search, set a high limit
params.setLimit(LC.calendar_resource_ldap_search_maxsize.intValue());
String attrsStr = request.getAttribute(AccountConstants.A_ATTRS, null);
String[] attrs = attrsStr == null ? null : attrsStr.split(",");
Set<String> attrsSet = attrs == null ? null : new HashSet<String>(Arrays.asList(attrs));
params.setResultCallback(new CalendarResourceGalSearchResultCallback(params, filter, attrsSet));
GalSearchControl gal = new GalSearchControl(params);
gal.search();
return params.getResultCallback().getResponse();
}
use of com.zimbra.cs.gal.GalSearchParams in project zm-mailbox by Zimbra.
the class TestLdapProvGal method searchGalADGroupMember.
@Test
@Ignore
public void searchGalADGroupMember() throws Exception {
String DOMAIN_NAME = genDomainSegmentName() + "." + baseDomainName();
Map<String, Object> domainAttrs = new HashMap<String, Object>();
domainAttrs.put(Provisioning.A_zimbraGalMode, ZAttrProvisioning.GalMode.ldap.name());
// replace XXX to real VMware AD credentials before checking in.
// NEVER check in the crdentials
domainAttrs.put(Provisioning.A_zimbraGalLdapURL, "ldap://XXX.vmware.com:3268");
domainAttrs.put(Provisioning.A_zimbraGalLdapBindDn, "XXX@vmware.com");
domainAttrs.put(Provisioning.A_zimbraGalLdapBindPassword, "XXX");
domainAttrs.put(Provisioning.A_zimbraGalLdapFilter, "ad");
domainAttrs.put(Provisioning.A_zimbraGalLdapGroupHandlerClass, "com.zimbra.cs.gal.ADGalGroupHandler");
Domain galDomain = provUtil.createDomain(DOMAIN_NAME, domainAttrs);
String ACCT_NAME_LOCALPART = Names.makeAccountNameLocalPart("searchGalADGroupMember");
Account user = provUtil.createAccount(ACCT_NAME_LOCALPART, galDomain, null);
GalSearchType type = GalSearchType.group;
String query = "server-pm@vmware.com";
GalSearchParams params = new GalSearchParams(user);
SearchGalResult result = SearchGalResult.newSearchGalResult(null);
params.setOp(GalOp.search);
params.setType(type);
// has to be set before calling createSearchConfig
params.setFetchGroupMembers(true);
params.createSearchConfig(GalSearchConfig.GalType.ldap);
params.setQuery(query);
params.setGalResult(result);
prov.searchGal(params);
assertEquals(1, result.getMatches().size());
GalContact galContact = result.getMatches().get(0);
assertTrue(galContact.isGroup());
Map<String, Object> galEntryAttrs = galContact.getAttrs();
Object members = galEntryAttrs.get(ContactConstants.A_member);
assertTrue(members instanceof String[]);
assertEquals(6, ((String[]) members).length);
}
Aggregations