Search in sources :

Example 1 with SearchDirectoryOptions

use of com.zimbra.cs.account.SearchDirectoryOptions in project zm-mailbox by Zimbra.

the class LdapProvisioning method getAllGroups.

/**
 * Get all static distribution lists and dynamic groups
 */
@SuppressWarnings("unchecked")
@Override
public List getAllGroups(Domain domain) throws ServiceException {
    SearchDirectoryOptions searchOpts = new SearchDirectoryOptions(domain);
    searchOpts.setFilter(mDIT.filterGroupsByDomain(domain));
    searchOpts.setTypes(ObjectType.distributionlists, ObjectType.dynamicgroups);
    searchOpts.setSortOpt(SortOpt.SORT_ASCENDING);
    List<NamedEntry> groups = (List<NamedEntry>) searchDirectoryInternal(searchOpts);
    return groups;
}
Also used : SearchDirectoryOptions(com.zimbra.cs.account.SearchDirectoryOptions) NamedEntry(com.zimbra.cs.account.NamedEntry) LdapDistributionList(com.zimbra.cs.account.ldap.entry.LdapDistributionList) ArrayList(java.util.ArrayList) List(java.util.List) AddressList(com.zimbra.cs.account.AddressList) DistributionList(com.zimbra.cs.account.DistributionList)

Example 2 with SearchDirectoryOptions

use of com.zimbra.cs.account.SearchDirectoryOptions in project zm-mailbox by Zimbra.

the class LdapProvisioning method getAllDistributionListsForAddresses.

@SuppressWarnings("unchecked")
private List<DistributionList> getAllDistributionListsForAddresses(String[] addrs, boolean basicAttrsOnly) throws ServiceException {
    if (addrs == null || addrs.length == 0)
        return new ArrayList<DistributionList>();
    String[] attrs = basicAttrsOnly ? BASIC_DL_ATTRS : null;
    SearchDirectoryOptions searchOpts = new SearchDirectoryOptions(attrs);
    searchOpts.setFilter(filterFactory.distributionListsByMemberAddrs(addrs));
    searchOpts.setTypes(ObjectType.distributionlists);
    searchOpts.setSortOpt(SortOpt.SORT_ASCENDING);
    return (List<DistributionList>) searchDirectoryInternal(searchOpts);
}
Also used : SearchDirectoryOptions(com.zimbra.cs.account.SearchDirectoryOptions) LdapDistributionList(com.zimbra.cs.account.ldap.entry.LdapDistributionList) ArrayList(java.util.ArrayList) List(java.util.List) AddressList(com.zimbra.cs.account.AddressList) DistributionList(com.zimbra.cs.account.DistributionList) LdapDistributionList(com.zimbra.cs.account.ldap.entry.LdapDistributionList) DistributionList(com.zimbra.cs.account.DistributionList)

Example 3 with SearchDirectoryOptions

use of com.zimbra.cs.account.SearchDirectoryOptions in project zm-mailbox by Zimbra.

the class LdapProvisioning method getDomainsByIds.

public void getDomainsByIds(NamedEntry.Visitor visitor, Collection<String> domains, String[] retAttrs) throws ServiceException {
    SearchDirectoryOptions opts = new SearchDirectoryOptions(retAttrs);
    opts.setFilter(filterFactory.domainsByIds(domains));
    opts.setTypes(ObjectType.domains);
    searchDirectoryInternal(opts, visitor);
}
Also used : SearchDirectoryOptions(com.zimbra.cs.account.SearchDirectoryOptions)

Example 4 with SearchDirectoryOptions

use of com.zimbra.cs.account.SearchDirectoryOptions in project zm-mailbox by Zimbra.

the class CustomLdapProvisioning method getAllDistributionLists.

@Override
public List<?> getAllDistributionLists(Domain domain) throws ServiceException {
    /* Don't specify domain in constructor - custom DIT doesn't necessarily store groups under the domain */
    SearchDirectoryOptions searchOpts = new SearchDirectoryOptions();
    searchOpts.setFilter(mDIT.filterDistributionListsByDomain(domain));
    searchOpts.setTypes(ObjectType.distributionlists);
    searchOpts.setSortOpt(SortOpt.SORT_ASCENDING);
    return searchDirectoryInternal(searchOpts);
}
Also used : SearchDirectoryOptions(com.zimbra.cs.account.SearchDirectoryOptions)

Example 5 with SearchDirectoryOptions

use of com.zimbra.cs.account.SearchDirectoryOptions in project zm-mailbox by Zimbra.

the class RenameDomain method execute.

public void execute() throws ServiceException {
    debug("Renaming domain %s(%s) to %s", mOldDomainName, mOldDomainId, mNewDomainName);
    RenameInfo renameInfo = beginRenameDomain();
    RenamePhase startingPhase = renameInfo.phase();
    RenamePhase phase = RenamePhase.FIX_FOREIGN_DL_MEMBERS;
    /*
         * 1. create the new domain
         */
    Domain newDomain = createNewDomain();
    debug("new domain: %s(%s)", newDomain.getName(), newDomain.getId());
    /*
         * 2. move all accounts, DLs, dynamic groups, and aliases
         */
    RenameDomainVisitor visitor;
    // first phase, move DLs, dynamic groups, and accounts and their aliases from
    // the old domain into the new domain
    phase = RenamePhase.RENAME_ENTRIES;
    if (phase.ordinal() >= startingPhase.ordinal()) {
        debug("Entering phase " + phase.toString());
        // don't need to setPhase for the first first, it was set or got from beginRenameDomain
        visitor = getVisitor(phase);
        SearchDirectoryOptions options = new SearchDirectoryOptions();
        options.setDomain(mOldDomain);
        options.setOnMaster(true);
        options.setFilterString(FilterId.RENAME_DOMAIN, null);
        options.setTypes(ObjectType.accounts, ObjectType.resources, ObjectType.distributionlists, ObjectType.dynamicgroups);
        mLdapHelper.searchDirectory(options, visitor);
    }
    // second phase, go thru aliases that have not been moved yet, by now aliases
    // left in the domain should be aliases with target in other domains
    phase = RenamePhase.FIX_FOREIGN_ALIASES;
    if (phase.ordinal() >= startingPhase.ordinal()) {
        debug("Entering phase " + phase.toString());
        renameInfo.setPhase(phase);
        renameInfo.write(mProv, mOldDomain);
        visitor = getVisitor(phase);
        SearchDirectoryOptions options = new SearchDirectoryOptions();
        options.setDomain(mOldDomain);
        options.setOnMaster(true);
        options.setFilterString(FilterId.RENAME_DOMAIN, null);
        options.setTypes(ObjectType.aliases);
        mLdapHelper.searchDirectory(options, visitor);
    }
    // third phase, go thru DLs and accounts in the *new* domain,
    // rename the addresses in all DLs
    // - the addresses to be renamed are: the DL/account's main address and
    // all the aliases that were moved to the new domain
    // - by now the DLs to modify should be those in other domains, because
    // members of DLs in the old domain (now new domain) have been updated
    // in the first pass.
    phase = RenamePhase.FIX_FOREIGN_DL_MEMBERS;
    if (phase.ordinal() >= startingPhase.ordinal()) {
        debug("Entering phase " + phase.toString());
        renameInfo.setPhase(phase);
        renameInfo.write(mProv, mOldDomain);
        visitor = getVisitor(phase);
        SearchDirectoryOptions options = new SearchDirectoryOptions();
        options.setDomain(newDomain);
        options.setOnMaster(true);
        options.setFilterString(FilterId.RENAME_DOMAIN, null);
        options.setTypes(ObjectType.accounts, ObjectType.resources, ObjectType.distributionlists);
        mLdapHelper.searchDirectory(options, visitor);
    }
    /*
         * 3. Delete the old domain
         */
    debug("Deleting old domain %s(%s)", mOldDomainName, mOldDomainId);
    // save zimbraDefaultDomainName because deleteDomain will erase it if it is the old domain
    String curDefaultDomain = mProv.getConfig().getAttr(Provisioning.A_zimbraDefaultDomainName);
    mProv.deleteDomainAfterRename(mOldDomainId);
    /*
         * 4. Modify system accounts that had been renamed
         */
    updateGlobalConfigSettings(curDefaultDomain);
    /*
         * 5. activate the new domain
         *    - restore zimbraId to the id of the old domain on the new domain
         *    - activate/enable the new domain
         */
    endRenameDomain(newDomain, mOldDomainId);
    /*
         * 6. fixup ZMPPComponments pointing to the renamed domain
         */
    fixupXMPPComponents();
    /*
         * 7. flush account cache on all servers
         */
    flushCacheOnAllServers(CacheEntryType.account);
}
Also used : SearchDirectoryOptions(com.zimbra.cs.account.SearchDirectoryOptions) Domain(com.zimbra.cs.account.Domain)

Aggregations

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