Search in sources :

Example 16 with SearchDirectoryOptions

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);
}
Also used : Account(com.zimbra.cs.account.Account) SearchDirectoryOptions(com.zimbra.cs.account.SearchDirectoryOptions) NamedEntry(com.zimbra.cs.account.NamedEntry) ProvTest(com.zimbra.qa.unittest.prov.ProvTest) Bug(com.zimbra.qa.QA.Bug)

Example 17 with SearchDirectoryOptions

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);
}
Also used : SearchDirectoryOptions(com.zimbra.cs.account.SearchDirectoryOptions)

Example 18 with SearchDirectoryOptions

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);
}
Also used : Account(com.zimbra.cs.account.Account) NamedEntry(com.zimbra.cs.account.NamedEntry) SearchDirectoryOptions(com.zimbra.cs.account.SearchDirectoryOptions) LdapDomain(com.zimbra.cs.account.ldap.entry.LdapDomain) CalendarResource(com.zimbra.cs.account.CalendarResource) DistributionList(com.zimbra.cs.account.DistributionList) ProvTest(com.zimbra.qa.unittest.prov.ProvTest)

Example 19 with SearchDirectoryOptions

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);
}
Also used : Account(com.zimbra.cs.account.Account) SearchDirectoryOptions(com.zimbra.cs.account.SearchDirectoryOptions) NamedEntry(com.zimbra.cs.account.NamedEntry) Domain(com.zimbra.cs.account.Domain) LdapDomain(com.zimbra.cs.account.ldap.entry.LdapDomain) ProvTest(com.zimbra.qa.unittest.prov.ProvTest)

Example 20 with SearchDirectoryOptions

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);
}
Also used : Account(com.zimbra.cs.account.Account) SearchDirectoryOptions(com.zimbra.cs.account.SearchDirectoryOptions) NamedEntry(com.zimbra.cs.account.NamedEntry) ProvTest(com.zimbra.qa.unittest.prov.ProvTest)

Aggregations

SearchDirectoryOptions (com.zimbra.cs.account.SearchDirectoryOptions)30 NamedEntry (com.zimbra.cs.account.NamedEntry)19 Account (com.zimbra.cs.account.Account)11 ProvTest (com.zimbra.qa.unittest.prov.ProvTest)9 Domain (com.zimbra.cs.account.Domain)8 DistributionList (com.zimbra.cs.account.DistributionList)7 LdapDomain (com.zimbra.cs.account.ldap.entry.LdapDomain)5 Provisioning (com.zimbra.cs.account.Provisioning)4 Element (com.zimbra.common.soap.Element)3 AccountServiceException (com.zimbra.cs.account.AccountServiceException)3 DynamicGroup (com.zimbra.cs.account.DynamicGroup)3 AdminSession (com.zimbra.cs.session.AdminSession)3 ZimbraSoapContext (com.zimbra.soap.ZimbraSoapContext)3 ArrayList (java.util.ArrayList)3 HashSet (java.util.HashSet)3 List (java.util.List)3 ServiceException (com.zimbra.common.service.ServiceException)2 Alias (com.zimbra.cs.account.Alias)2 CalendarResource (com.zimbra.cs.account.CalendarResource)2 LdapDistributionList (com.zimbra.cs.account.ldap.entry.LdapDistributionList)2