use of com.zimbra.cs.account.ldap.LdapProv in project zm-mailbox by Zimbra.
the class Cleanup method deleteAllNonDefaultServers.
private static void deleteAllNonDefaultServers() throws Exception {
LdapProv ldapProv = LdapProv.getInst();
LdapDIT dit = ldapProv.getDIT();
String serverBaseDN = dit.serverBaseDN();
Set<String> defaultServerDN = new HashSet<String>();
defaultServerDN.add(dit.serverNameToDN(ldapProv.getLocalServer().getName()));
deleteAllChildrenUnderDN(serverBaseDN, defaultServerDN);
}
use of com.zimbra.cs.account.ldap.LdapProv in project zm-mailbox by Zimbra.
the class ExternalGroup method searchGroup.
private static ExternalGroup searchGroup(DomainBy domainBy, String extGroupGrantee, boolean asAdmin) throws ServiceException {
LdapProv prov = LdapProv.getInst();
ExternalGroupInfo extGrpInfo = ExternalGroupInfo.parse(extGroupGrantee);
String zimbraDomain = extGrpInfo.getZimbraDmain();
String extGroupName = extGrpInfo.getExternalGroupName();
Domain domain = prov.get(domainBy, zimbraDomain);
if (domain == null) {
throw AccountServiceException.NO_SUCH_DOMAIN(zimbraDomain);
}
String searchBase = domain.getExternalGroupLdapSearchBase();
String filterTemplate = domain.getExternalGroupLdapSearchFilter();
if (searchBase == null) {
searchBase = LdapConstants.DN_ROOT_DSE;
}
String searchFilter = LdapUtil.computeDn(extGroupName, filterTemplate);
GroupHandler groupHandler = getGroupHandler(domain);
ZLdapContext zlc = null;
try {
zlc = groupHandler.getExternalDelegatedAdminGroupsLdapContext(domain, asAdmin);
ZSearchResultEntry entry = prov.getHelper().searchForEntry(searchBase, FilterId.EXTERNAL_GROUP, searchFilter, zlc, new String[] { "mail" });
if (entry != null) {
return makeExternalGroup(domain, groupHandler, extGroupName, entry.getDN(), entry.getAttributes());
} else {
return null;
}
} finally {
LdapClient.closeContext(zlc);
}
}
use of com.zimbra.cs.account.ldap.LdapProv in project zm-mailbox by Zimbra.
the class TestLdapProvRenameDomain method renameToExistingDomainTest.
private void renameToExistingDomainTest() throws Exception {
setLdapProv();
String srcDomainName = DOMAIN_NAME("src");
String tgtDomainName = DOMAIN_NAME("target");
Domain srcDomain = prov.createDomain(srcDomainName, new HashMap<String, Object>());
assertNotNull(srcDomain);
Domain tgtDomain = prov.createDomain(tgtDomainName, new HashMap<String, Object>());
assertNotNull(tgtDomain);
boolean ok = false;
try {
((LdapProv) prov).renameDomain(srcDomain.getId(), tgtDomainName);
} catch (ServiceException e) {
assertEquals(ServiceException.INVALID_REQUEST, e.getCode());
assertEquals("invalid request: domain " + new Names.IDNName(tgtDomainName).aName() + " already exists", e.getMessage());
}
verifyDomainStatus(srcDomainName);
verifyDomainStatus(tgtDomainName);
}
use of com.zimbra.cs.account.ldap.LdapProv in project zm-mailbox by Zimbra.
the class TestLdap method deleteAllNonDefaultServers.
private static void deleteAllNonDefaultServers() throws Exception {
LdapProv ldapProv = LdapProv.getInst();
LdapDIT dit = ldapProv.getDIT();
String serverBaseDN = dit.serverBaseDN();
Set<String> defaultServerDN = new HashSet<String>();
defaultServerDN.add(dit.serverNameToDN(ldapProv.getLocalServer().getName()));
deleteAllChildrenUnderDN(serverBaseDN, defaultServerDN);
}
use of com.zimbra.cs.account.ldap.LdapProv in project zm-mailbox by Zimbra.
the class TestLdapProvExternalLdapAuth method externalLdapAuthByBindDNtemplate.
@Test
public void externalLdapAuthByBindDNtemplate() throws Exception {
LdapProv ldapProv = (LdapProv) prov;
String DOMAIN_NAME = Names.makeDomainName(genDomainSegmentName() + "." + baseDomainName());
String authMech = AuthMech.ldap.name();
Map<String, Object> domainAttrs = new HashMap<String, Object>();
domainAttrs.put(Provisioning.A_zimbraAuthMech, authMech);
domainAttrs.put(Provisioning.A_zimbraAuthLdapURL, getLdapURL());
domainAttrs.put(Provisioning.A_zimbraAuthLdapStartTlsEnabled, getWantStartTLS());
domainAttrs.put(Provisioning.A_zimbraAuthLdapSearchBindPassword, LC.zimbra_ldap_password.value());
domainAttrs.put(Provisioning.A_zimbraAuthLdapSearchBindDn, LC.zimbra_ldap_userdn.value());
domainAttrs.put(Provisioning.A_zimbraAuthLdapBindDn, "uid=%u,ou=people,%D");
Domain domain = provUtil.createDomain(DOMAIN_NAME, domainAttrs);
// TODO: doesn't work with special chars, even in the legacy implementation.
// String ACCT_NAME_LOCALPART = TestLdap.makeAccountNameLocalPart("checkAuthConfigByBindDNTemplate");
// String ACCT_NAME_LOCALPART = TestLdap.makeAccountNameLocalPart("externalLdapAuthByDNOnAccount");
String ACCT_NAME_LOCALPART = Names.makeAccountNameLocalPart(genAcctNameLocalPart());
Account acct = provUtil.createAccount(ACCT_NAME_LOCALPART, domain);
prov.authAccount(acct, "test123", AuthContext.Protocol.test);
provUtil.deleteAccount(acct);
}
Aggregations