use of com.zimbra.cs.ldap.IAttributes in project zm-mailbox by Zimbra.
the class BUG_57866 method upgradeWikiAccounts.
private void upgradeWikiAccounts(ZLdapContext zlc) throws ServiceException {
// global wiki account
String acctName = prov.getConfig().getNotebookAccount();
if (acctName != null) {
printer.format("Checking global wiki account %s\n", acctName);
Account acct = prov.get(AccountBy.name, acctName);
setIsSystemAccount(zlc, acct);
}
// domain wiki accounts
LdapDIT dit = prov.getDIT();
String[] returnAttrs = new String[] { Provisioning.A_zimbraNotebookAccount };
String base = dit.mailBranchBaseDN();
String query = "(&(objectclass=zimbraDomain)(zimbraNotebookAccount=*))";
final Set<String> wikiAcctNames = new HashSet<String>();
SearchLdapVisitor visitor = new SearchLdapVisitor(false) {
@Override
public void visit(String dn, IAttributes ldapAttrs) throws StopIteratingException {
try {
String acctName;
acctName = ldapAttrs.getAttrString(Provisioning.A_zimbraNotebookAccount);
if (acctName != null) {
wikiAcctNames.add(acctName);
}
} catch (ServiceException e) {
printer.printStackTrace("unsble to search domains for wiki accounts", e);
}
}
};
SearchLdapOptions searchOpts = new SearchLdapOptions(base, getFilter(query), returnAttrs, SearchLdapOptions.SIZE_UNLIMITED, null, ZSearchScope.SEARCH_SCOPE_SUBTREE, visitor);
zlc.searchPaged(searchOpts);
for (String wikiAcctName : wikiAcctNames) {
printer.format("Checking domain wiki account %s\n", wikiAcctName);
Account acct = prov.get(AccountBy.name, wikiAcctName);
setIsSystemAccount(zlc, acct);
}
}
Aggregations