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