use of com.zimbra.cs.account.ldap.LdapDIT in project zm-mailbox by Zimbra.
the class CollectAllEffectiveRights method getAllGroups.
private Set<String> getAllGroups() throws ServiceException {
LdapDIT ldapDIT = mProv.getDIT();
String base = ldapDIT.mailBranchBaseDN();
ZLdapFilter filter = ZLdapFilterFactory.getInstance().allGroups();
// hack, see LDAPDIT.dnToEmail, for now we get naming rdn for both default and possible custom DIT
String[] returnAttrs = new String[] { Provisioning.A_cn, Provisioning.A_uid };
Visitor visitor = new Visitor(mProv);
mProv.searchLdapOnMaster(base, filter, returnAttrs, visitor);
return visitor.getResult();
}
use of com.zimbra.cs.account.ldap.LdapDIT in project zm-mailbox by Zimbra.
the class BUG_18277 method getAllDomainOrGlobalAdmins.
private void getAllDomainOrGlobalAdmins(Set<String> domainAdminIds, Set<String> globalAdminIds) throws ServiceException {
LdapDIT dit = prov.getDIT();
String[] returnAttrs = new String[] { Provisioning.A_objectClass, Provisioning.A_zimbraId, Provisioning.A_zimbraIsAdminAccount, Provisioning.A_zimbraIsDomainAdminAccount, Provisioning.A_zimbraIsDelegatedAdminAccount };
String configBranchBaseDn = dit.configBranchBaseDN();
String base = dit.mailBranchBaseDN();
String query = "(&(objectclass=zimbraAccount)(|(zimbraIsDomainAdminAccount=TRUE)(zimbraIsAdminAccount=TRUE)))";
ZLdapContext zlc = null;
try {
zlc = LdapClient.getContext(LdapServerType.MASTER, LdapUsage.UPGRADE);
Bug18277Visitor visitor = new Bug18277Visitor(this, configBranchBaseDn, domainAdminIds, globalAdminIds);
SearchLdapOptions searchOpts = new SearchLdapOptions(base, getFilter(query), returnAttrs, SearchLdapOptions.SIZE_UNLIMITED, null, ZSearchScope.SEARCH_SCOPE_SUBTREE, visitor);
zlc.searchPaged(searchOpts);
} catch (ServiceException e) {
throw ServiceException.FAILURE("unable to list all objects", e);
} finally {
LdapClient.closeContext(zlc);
}
}
use of com.zimbra.cs.account.ldap.LdapDIT in project zm-mailbox by Zimbra.
the class BUG_57866 method upgradeGalSyncAccounts.
private void upgradeGalSyncAccounts(ZLdapContext zlc) throws ServiceException {
LdapDIT dit = prov.getDIT();
String[] returnAttrs = new String[] { Provisioning.A_zimbraGalAccountId };
String base = dit.mailBranchBaseDN();
String query = "(&(objectclass=zimbraDomain)(zimbraGalAccountId=*))";
final Set<String> galAcctIds = new HashSet<String>();
SearchLdapVisitor visitor = new SearchLdapVisitor(false) {
@Override
public void visit(String dn, IAttributes ldapAttrs) throws StopIteratingException {
try {
String acctId;
acctId = ldapAttrs.getAttrString(Provisioning.A_zimbraGalAccountId);
if (acctId != null) {
galAcctIds.add(acctId);
}
} catch (ServiceException e) {
printer.printStackTrace("unsble to search domains for GAL sync accounts", e);
}
}
};
SearchLdapOptions searchOpts = new SearchLdapOptions(base, getFilter(query), returnAttrs, SearchLdapOptions.SIZE_UNLIMITED, null, ZSearchScope.SEARCH_SCOPE_SUBTREE, visitor);
zlc.searchPaged(searchOpts);
for (String galAcctId : galAcctIds) {
printer.format("Checking GAL sync account %s\n", galAcctId);
Account acct = prov.get(AccountBy.id, galAcctId);
setIsSystemAccount(zlc, acct);
}
}
use of com.zimbra.cs.account.ldap.LdapDIT in project zm-mailbox by Zimbra.
the class TestLdapHelper method searchForEntryMultipleMatchedEntries.
@Test
public void searchForEntryMultipleMatchedEntries() throws Exception {
LdapDIT dit = prov.getDIT();
String base = dit.configBranchBaseDN();
ZLdapFilter filter = filterFactory.allAccounts();
boolean caughtException = false;
try {
ZSearchResultEntry entry = ldapHelper.searchForEntry(base, filter, null, false);
assertNotNull(entry);
} catch (LdapMultipleEntriesMatchedException e) {
caughtException = true;
}
assertTrue(caughtException);
}
use of com.zimbra.cs.account.ldap.LdapDIT in project zm-mailbox by Zimbra.
the class TestLdapHelper method searchDir.
@Test
public void searchDir() throws Exception {
LdapDIT dit = prov.getDIT();
String base = dit.configBranchBaseDN();
ZLdapFilter filter = filterFactory.anyEntry();
String[] returnAttrs = new String[] { "objectClass" };
ZSearchControls searchControls = ZSearchControls.createSearchControls(ZSearchScope.SEARCH_SCOPE_ONELEVEL, ZSearchControls.SIZE_UNLIMITED, returnAttrs);
ZSearchResultEnumeration ne = ldapHelper.searchDir(base, filter, searchControls);
Set<String> expected = new HashSet<String>();
expected.add(dit.adminBaseDN());
expected.add(dit.appAdminBaseDN());
expected.add(dit.zimletBaseDN());
expected.add(dit.cosBaseDN());
expected.add(dit.globalDynamicGroupBaseDN());
expected.add(dit.serverBaseDN());
expected.add(dit.xmppcomponentBaseDN());
expected.add(dit.globalGrantDN());
expected.add(dit.configDN());
expected.add(dit.shareLocatorBaseDN());
expected.add(dit.ucServiceBaseDN());
int numFound = 0;
while (ne.hasMore()) {
ZSearchResultEntry sr = ne.next();
assertTrue(expected.contains(sr.getDN()));
numFound++;
}
ne.close();
assertEquals(expected.size(), numFound);
}
Aggregations