Search in sources :

Example 26 with LdapProv

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);
}
Also used : LdapDIT(com.zimbra.cs.account.ldap.LdapDIT) LdapProv(com.zimbra.cs.account.ldap.LdapProv) HashSet(java.util.HashSet)

Example 27 with LdapProv

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);
    }
}
Also used : ZLdapContext(com.zimbra.cs.ldap.ZLdapContext) GroupHandler(com.zimbra.cs.account.grouphandler.GroupHandler) Domain(com.zimbra.cs.account.Domain) ExternalGroupInfo(com.zimbra.cs.account.accesscontrol.ZimbraACE.ExternalGroupInfo) LdapProv(com.zimbra.cs.account.ldap.LdapProv) ZSearchResultEntry(com.zimbra.cs.ldap.ZSearchResultEntry)

Example 28 with LdapProv

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);
}
Also used : Names(com.zimbra.qa.unittest.prov.Names) ServiceException(com.zimbra.common.service.ServiceException) Domain(com.zimbra.cs.account.Domain) LdapProv(com.zimbra.cs.account.ldap.LdapProv)

Example 29 with LdapProv

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);
}
Also used : LdapDIT(com.zimbra.cs.account.ldap.LdapDIT) LdapProv(com.zimbra.cs.account.ldap.LdapProv) HashSet(java.util.HashSet)

Example 30 with LdapProv

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);
}
Also used : Account(com.zimbra.cs.account.Account) HashMap(java.util.HashMap) Domain(com.zimbra.cs.account.Domain) LdapProv(com.zimbra.cs.account.ldap.LdapProv) ProvTest(com.zimbra.qa.unittest.prov.ProvTest)

Aggregations

LdapProv (com.zimbra.cs.account.ldap.LdapProv)38 Domain (com.zimbra.cs.account.Domain)14 Account (com.zimbra.cs.account.Account)12 HashMap (java.util.HashMap)12 DistributionList (com.zimbra.cs.account.DistributionList)8 Provisioning (com.zimbra.cs.account.Provisioning)8 ServiceException (com.zimbra.common.service.ServiceException)7 NamedEntry (com.zimbra.cs.account.NamedEntry)6 LdapEntry (com.zimbra.cs.account.ldap.entry.LdapEntry)6 HashSet (java.util.HashSet)6 Map (java.util.Map)5 AccountServiceException (com.zimbra.cs.account.AccountServiceException)4 LdapDIT (com.zimbra.cs.account.ldap.LdapDIT)4 List (java.util.List)4 Entry (com.zimbra.cs.account.Entry)3 CacheEntry (com.zimbra.cs.account.Provisioning.CacheEntry)3 RightCommand (com.zimbra.cs.account.accesscontrol.RightCommand)3 ZLdapContext (com.zimbra.cs.ldap.ZLdapContext)3 GranteeBy (com.zimbra.soap.admin.type.GranteeSelector.GranteeBy)3 PublishedShareInfoVisitor (com.zimbra.cs.account.Provisioning.PublishedShareInfoVisitor)2