use of com.zimbra.cs.account.SearchDirectoryOptions in project zm-mailbox by Zimbra.
the class TestLdapProvSearchDirectory method wildcardFilter.
@Test
@Bug(bug = 67379)
public void wildcardFilter() throws Exception {
Account acct1 = createAccount(genAcctNameLocalPart("1"));
Account acct2 = createAccount(genAcctNameLocalPart("2"));
Account acct3 = createAccount(genAcctNameLocalPart("3"));
SearchDirectoryOptions options = new SearchDirectoryOptions(domain);
options.setTypes(ObjectType.accounts);
options.setSortOpt(SortOpt.SORT_ASCENDING);
options.setFilterString(FilterId.UNITTEST, "(cn=*)");
options.setConvertIDNToAscii(true);
List<NamedEntry> entries = prov.searchDirectory(options);
Verify.verifyEquals(Lists.newArrayList(acct1, acct2, acct3), entries, true);
deleteAccount(acct1);
deleteAccount(acct2);
deleteAccount(acct3);
}
use of com.zimbra.cs.account.SearchDirectoryOptions in project zm-mailbox by Zimbra.
the class LdapProvisioning method getAllCalendarResources.
@Override
public void getAllCalendarResources(Domain domain, NamedEntry.Visitor visitor) throws ServiceException {
SearchDirectoryOptions searchOpts = new SearchDirectoryOptions(domain);
searchOpts.setFilter(mDIT.filterCalendarResourcesByDomain(domain));
searchOpts.setTypes(ObjectType.resources);
searchDirectoryInternal(searchOpts, visitor);
}
use of com.zimbra.cs.account.SearchDirectoryOptions in project zm-mailbox by Zimbra.
the class TestLdapProvSearchDirectory method renameDomainSearchAcctCrDl.
@Test
public void renameDomainSearchAcctCrDl() throws Exception {
Account acct = createAccount(genAcctNameLocalPart("acct"));
CalendarResource cr = createCalendarResource(genAcctNameLocalPart("cr"));
DistributionList dl = createDistributionList(genGroupNameLocalPart("dl"));
String domainDN = ((LdapDomain) domain).getDN();
String searchBase = ((LdapProv) prov).getDIT().domainDNToAccountSearchDN(domainDN);
final List<NamedEntry> entries = Lists.newArrayList();
NamedEntry.Visitor visitor = new NamedEntry.Visitor() {
@Override
public void visit(NamedEntry entry) throws ServiceException {
// System.out.println(entry.getName());
entries.add(entry);
}
};
SearchDirectoryOptions options = new SearchDirectoryOptions();
options.setDomain(domain);
options.setOnMaster(true);
options.setFilterString(FilterId.RENAME_DOMAIN, null);
options.setTypes(ObjectType.accounts, ObjectType.resources, ObjectType.distributionlists);
prov.searchDirectory(options, visitor);
Verify.verifyEquals(Lists.newArrayList(acct, cr, dl), entries, false);
/*
// legacy code and ldap trace
int flags = Provisioning.SD_ACCOUNT_FLAG + Provisioning.SD_CALENDAR_RESOURCE_FLAG + Provisioning.SD_DISTRIBUTION_LIST_FLAG;
((LdapProvisioning) prov).searchObjects(null, null, searchBase, flags, visitor, 0);
*
Oct 12 22:10:43 pshao-macbookpro-2 slapd[3065]: conn=1081 op=434 SRCH base="ou=people,dc=com,dc=zimbra,dc=qa,dc=unittest,dc=testldapprovsearchdirectory" scope=2 deref=0 filter="(|(objectClass=zimbraAccount)(objectClass=zimbraDistributionList)(objectClass=zimbraCalendarResource))"
Oct 12 22:10:43 pshao-macbookpro-2 slapd[3065]: conn=1081 op=434 SEARCH RESULT tag=101 err=0 nentries=3 text=
*/
deleteAccount(acct);
deleteAccount(cr);
deleteGroup(dl);
}
use of com.zimbra.cs.account.SearchDirectoryOptions in project zm-mailbox by Zimbra.
the class TestLdapProvSearchDirectory method idnFilter.
@Test
public void idnFilter() throws Exception {
String idnDomainUnicodeName = "中文" + "." + baseDomainName();
Domain idnDomain = provUtil.createDomain(idnDomainUnicodeName);
String acctNameLocalPart = genAcctNameLocalPart();
Account acct = provUtil.createAccount(acctNameLocalPart, idnDomain);
String acctUnicodeName = acctNameLocalPart + "@" + idnDomainUnicodeName;
SearchDirectoryOptions options = new SearchDirectoryOptions(idnDomain);
options.setTypes(ObjectType.accounts);
options.setSortOpt(SortOpt.SORT_ASCENDING);
options.setFilterString(FilterId.UNITTEST, String.format("(zimbraMailDeliveryAddress=%s)", acctUnicodeName));
options.setConvertIDNToAscii(true);
List<NamedEntry> entries = prov.searchDirectory(options);
Verify.verifyEquals(Lists.newArrayList(acct), entries, true);
deleteAccount(acct);
}
use of com.zimbra.cs.account.SearchDirectoryOptions in project zm-mailbox by Zimbra.
the class TestLdapProvSearchDirectory method chineseFilter.
@Test
public void chineseFilter() throws Exception {
Map<String, Object> acct1Attrs = Maps.newHashMap();
acct1Attrs.put(Provisioning.A_cn, "中文 1");
Account acct1 = createAccount(genAcctNameLocalPart("1"), acct1Attrs);
Map<String, Object> acct2Attrs = Maps.newHashMap();
acct2Attrs.put(Provisioning.A_cn, "中文 2");
Account acct2 = createAccount(genAcctNameLocalPart("2"), acct2Attrs);
Map<String, Object> acct3Attrs = Maps.newHashMap();
acct3Attrs.put(Provisioning.A_cn, "中文 3");
Account acct3 = createAccount(genAcctNameLocalPart("3"), acct3Attrs);
SearchDirectoryOptions options = new SearchDirectoryOptions(domain);
options.setTypes(ObjectType.accounts);
options.setSortOpt(SortOpt.SORT_ASCENDING);
options.setFilterString(FilterId.UNITTEST, "(cn=中文 2)");
options.setConvertIDNToAscii(true);
List<NamedEntry> entries = prov.searchDirectory(options);
Verify.verifyEquals(Lists.newArrayList(acct2), entries, true);
deleteAccount(acct1);
deleteAccount(acct2);
deleteAccount(acct3);
}
Aggregations