use of com.zimbra.cs.account.SearchDirectoryOptions in project zm-mailbox by Zimbra.
the class LdapProvisioning method renameDomain.
// LdapProv
@Override
public void renameDomain(String zimbraId, String newDomainName) throws ServiceException {
newDomainName = newDomainName.toLowerCase().trim();
newDomainName = IDNUtil.toAsciiDomainName(newDomainName);
NameUtil.validNewDomainName(newDomainName);
ZLdapContext zlc = null;
try {
zlc = LdapClient.getContext(LdapServerType.MASTER, LdapUsage.RENAME_DOMAIN);
RenameDomain.RenameDomainLdapHelper helper = new RenameDomain.RenameDomainLdapHelper(this, zlc) {
private ZLdapContext toZLdapContext() {
return LdapClient.toZLdapContext(mProv, mZlc);
}
@Override
public void createEntry(String dn, Map<String, Object> attrs) throws ServiceException {
ZMutableEntry entry = LdapClient.createMutableEntry();
entry.mapToAttrs(attrs);
entry.setDN(dn);
ZLdapContext ldapContext = toZLdapContext();
ldapContext.createEntry(entry);
}
@Override
public void deleteEntry(String dn) throws ServiceException {
ZLdapContext ldapContext = toZLdapContext();
ldapContext.deleteEntry(dn);
}
@Override
public void renameEntry(String oldDn, String newDn) throws ServiceException {
ZLdapContext ldapContext = toZLdapContext();
ldapContext.renameEntry(oldDn, newDn);
}
@Override
public void searchDirectory(SearchDirectoryOptions options, NamedEntry.Visitor visitor) throws ServiceException {
((LdapProvisioning) mProv).searchDirectory(options, visitor);
}
@Override
public void renameAddressesInAllDistributionLists(Map<String, String> changedPairs) {
((LdapProvisioning) mProv).renameAddressesInAllDistributionLists(changedPairs);
}
@Override
public void renameXMPPComponent(String zimbraId, String newName) throws ServiceException {
((LdapProvisioning) mProv).renameXMPPComponent(zimbraId, newName);
}
@Override
public Account getAccountById(String id) throws ServiceException {
// note: we do NOT want to get a cached entry
return ((LdapProvisioning) mProv).getAccountByQuery(mProv.getDIT().mailBranchBaseDN(), ZLdapFilterFactory.getInstance().accountById(id), toZLdapContext(), true);
}
@Override
public DistributionList getDistributionListById(String id) throws ServiceException {
// note: we do NOT want to get a cahed entry
return ((LdapProvisioning) mProv).getDistributionListByQuery(mDIT.mailBranchBaseDN(), filterFactory.distributionListById(id), toZLdapContext(), false);
}
@Override
public DynamicGroup getDynamicGroupById(String id) throws ServiceException {
// note: we do NOT want to get a cahed entry
return ((LdapProvisioning) mProv).getDynamicGroupByQuery(filterFactory.dynamicGroupById(id), toZLdapContext(), false);
}
@Override
public void modifyLdapAttrs(Entry entry, Map<String, ? extends Object> attrs) throws ServiceException {
((LdapProvisioning) mProv).modifyLdapAttrs(entry, toZLdapContext(), attrs);
}
};
Domain oldDomain = getDomainById(zimbraId, zlc);
if (oldDomain == null)
throw AccountServiceException.NO_SUCH_DOMAIN(zimbraId);
RenameDomain rd = new RenameDomain(this, helper, oldDomain, newDomainName);
rd.execute();
} finally {
LdapClient.closeContext(zlc);
}
}
use of com.zimbra.cs.account.SearchDirectoryOptions in project zm-mailbox by Zimbra.
the class LdapProvisioning method getAllDomains.
@Override
public void getAllDomains(NamedEntry.Visitor visitor, String[] retAttrs) throws ServiceException {
SearchDirectoryOptions opts = new SearchDirectoryOptions(retAttrs);
opts.setFilter(filterFactory.allDomains());
opts.setTypes(ObjectType.domains);
searchDirectoryInternal(opts, visitor);
}
use of com.zimbra.cs.account.SearchDirectoryOptions in project zm-mailbox by Zimbra.
the class LdapProvisioning method getAllDistributionLists.
@Override
public List<?> getAllDistributionLists(Domain domain) throws ServiceException {
SearchDirectoryOptions searchOpts = new SearchDirectoryOptions(domain);
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 LdapProvisioning method getAllCalendarResources.
@Override
public List<?> getAllCalendarResources(Domain domain) throws ServiceException {
SearchDirectoryOptions searchOpts = new SearchDirectoryOptions(domain);
searchOpts.setFilter(mDIT.filterCalendarResourcesByDomain(domain));
searchOpts.setTypes(ObjectType.resources);
searchOpts.setSortOpt(SortOpt.SORT_ASCENDING);
return searchDirectoryInternal(searchOpts);
}
use of com.zimbra.cs.account.SearchDirectoryOptions in project zm-mailbox by Zimbra.
the class BUG_66387 method searchAndFixAccounts.
private int searchAndFixAccounts() throws ServiceException {
String[] attrsToGet = new String[] { Provisioning.A_zimbraAllowFromAddress };
SearchDirectoryOptions searchOpts = new SearchDirectoryOptions(attrsToGet);
searchOpts.setTypes(SearchDirectoryOptions.ObjectType.accounts, SearchDirectoryOptions.ObjectType.resources);
searchOpts.setSortOpt(SortOpt.SORT_ASCENDING);
searchOpts.setSortAttr(Provisioning.A_zimbraMailDeliveryAddress);
searchOpts.setMakeObjectOpt(MakeObjectOpt.NO_DEFAULTS);
searchOpts.setFilterString(FilterId.LDAP_UPGRADE, "(" + Provisioning.A_zimbraAllowFromAddress + "=*)");
List<NamedEntry> accounts = prov.searchDirectory(searchOpts);
for (int i = 0; i < accounts.size(); ++i) {
NamedEntry entry = accounts.get(i);
if (entry instanceof Account) {
Account acct = (Account) entry;
fixAccount(acct.getName(), acct.getAllowFromAddress());
}
}
return accounts.size();
}
Aggregations