Search in sources :

Example 1 with LdapUCService

use of com.zimbra.cs.account.ldap.entry.LdapUCService in project zm-mailbox by Zimbra.

the class LdapProvisioning method getUCServiceByName.

private UCService getUCServiceByName(String name, boolean nocache) throws ServiceException {
    if (!nocache) {
        UCService s = ucServiceCache.getByName(name);
        if (s != null) {
            return s;
        }
    }
    try {
        String dn = mDIT.ucServiceNameToDN(name);
        ZAttributes attrs = helper.getAttributes(LdapUsage.GET_UCSERVICE, dn);
        LdapUCService s = new LdapUCService(dn, attrs, this);
        ucServiceCache.put(s);
        return s;
    } catch (LdapEntryNotFoundException e) {
        return null;
    } catch (ServiceException e) {
        throw ServiceException.FAILURE("unable to lookup ucservice by name: " + name + " message: " + e.getMessage(), e);
    }
}
Also used : LdapUCService(com.zimbra.cs.account.ldap.entry.LdapUCService) UCService(com.zimbra.cs.account.UCService) AccountServiceException(com.zimbra.cs.account.AccountServiceException) AuthFailedServiceException(com.zimbra.cs.account.AccountServiceException.AuthFailedServiceException) ServiceException(com.zimbra.common.service.ServiceException) LdapEntryNotFoundException(com.zimbra.cs.ldap.LdapException.LdapEntryNotFoundException) ZAttributes(com.zimbra.cs.ldap.ZAttributes) LdapUCService(com.zimbra.cs.account.ldap.entry.LdapUCService)

Example 2 with LdapUCService

use of com.zimbra.cs.account.ldap.entry.LdapUCService in project zm-mailbox by Zimbra.

the class LdapProvisioning method renameUCService.

@Override
public void renameUCService(String zimbraId, String newName) throws ServiceException {
    LdapUCService ucService = (LdapUCService) getUCServiceById(zimbraId, null, false);
    if (ucService == null) {
        throw AccountServiceException.NO_SUCH_UC_SERVICE(zimbraId);
    }
    ZLdapContext zlc = null;
    try {
        zlc = LdapClient.getContext(LdapServerType.MASTER, LdapUsage.RENAME_UCSERVICE);
        String newDn = mDIT.ucServiceNameToDN(newName);
        zlc.renameEntry(ucService.getDN(), newDn);
        ucServiceCache.remove(ucService);
    } catch (LdapEntryAlreadyExistException nabe) {
        throw AccountServiceException.UC_SERVICE_EXISTS(newName);
    } catch (LdapException e) {
        throw e;
    } catch (AccountServiceException e) {
        throw e;
    } catch (ServiceException e) {
        throw ServiceException.FAILURE("unable to rename ucservice: " + zimbraId, e);
    } finally {
        LdapClient.closeContext(zlc);
    }
}
Also used : LdapEntryAlreadyExistException(com.zimbra.cs.ldap.LdapException.LdapEntryAlreadyExistException) AccountServiceException(com.zimbra.cs.account.AccountServiceException) ZLdapContext(com.zimbra.cs.ldap.ZLdapContext) AccountServiceException(com.zimbra.cs.account.AccountServiceException) AuthFailedServiceException(com.zimbra.cs.account.AccountServiceException.AuthFailedServiceException) ServiceException(com.zimbra.common.service.ServiceException) LdapUCService(com.zimbra.cs.account.ldap.entry.LdapUCService) LdapException(com.zimbra.cs.ldap.LdapException)

Example 3 with LdapUCService

use of com.zimbra.cs.account.ldap.entry.LdapUCService in project zm-mailbox by Zimbra.

the class LdapProvisioning method deleteUCService.

@Override
public void deleteUCService(String zimbraId) throws ServiceException {
    LdapUCService ucService = (LdapUCService) getUCServiceById(zimbraId, null, false);
    if (ucService == null) {
        throw AccountServiceException.NO_SUCH_UC_SERVICE(zimbraId);
    }
    ZLdapContext zlc = null;
    try {
        zlc = LdapClient.getContext(LdapServerType.MASTER, LdapUsage.DELETE_UCSERVICE);
        zlc.deleteEntry(ucService.getDN());
        ucServiceCache.remove(ucService);
    } catch (ServiceException e) {
        throw ServiceException.FAILURE("unable to purge ucservice: " + zimbraId, e);
    } finally {
        LdapClient.closeContext(zlc);
    }
}
Also used : ZLdapContext(com.zimbra.cs.ldap.ZLdapContext) AccountServiceException(com.zimbra.cs.account.AccountServiceException) AuthFailedServiceException(com.zimbra.cs.account.AccountServiceException.AuthFailedServiceException) ServiceException(com.zimbra.common.service.ServiceException) LdapUCService(com.zimbra.cs.account.ldap.entry.LdapUCService)

Example 4 with LdapUCService

use of com.zimbra.cs.account.ldap.entry.LdapUCService in project zm-mailbox by Zimbra.

the class LdapProvisioning method getAllUCServices.

@Override
public List<UCService> getAllUCServices() throws ServiceException {
    List<UCService> result = new ArrayList<UCService>();
    ZLdapFilter filter = filterFactory.allUCServices();
    try {
        ZSearchResultEnumeration ne = helper.searchDir(mDIT.ucServiceBaseDN(), filter, ZSearchControls.SEARCH_CTLS_SUBTREE());
        while (ne.hasMore()) {
            ZSearchResultEntry sr = ne.next();
            LdapUCService s = new LdapUCService(sr.getDN(), sr.getAttributes(), this);
            result.add(s);
        }
        ne.close();
    } catch (ServiceException e) {
        throw ServiceException.FAILURE("unable to list all servers", e);
    }
    if (result.size() > 0) {
        ucServiceCache.put(result, true);
    }
    Collections.sort(result);
    return result;
}
Also used : ZLdapFilter(com.zimbra.cs.ldap.ZLdapFilter) LdapUCService(com.zimbra.cs.account.ldap.entry.LdapUCService) UCService(com.zimbra.cs.account.UCService) AccountServiceException(com.zimbra.cs.account.AccountServiceException) AuthFailedServiceException(com.zimbra.cs.account.AccountServiceException.AuthFailedServiceException) ServiceException(com.zimbra.common.service.ServiceException) ZSearchResultEnumeration(com.zimbra.cs.ldap.ZSearchResultEnumeration) LdapUCService(com.zimbra.cs.account.ldap.entry.LdapUCService) ArrayList(java.util.ArrayList) ZSearchResultEntry(com.zimbra.cs.ldap.ZSearchResultEntry)

Aggregations

ServiceException (com.zimbra.common.service.ServiceException)4 AccountServiceException (com.zimbra.cs.account.AccountServiceException)4 AuthFailedServiceException (com.zimbra.cs.account.AccountServiceException.AuthFailedServiceException)4 LdapUCService (com.zimbra.cs.account.ldap.entry.LdapUCService)4 UCService (com.zimbra.cs.account.UCService)2 ZLdapContext (com.zimbra.cs.ldap.ZLdapContext)2 LdapException (com.zimbra.cs.ldap.LdapException)1 LdapEntryAlreadyExistException (com.zimbra.cs.ldap.LdapException.LdapEntryAlreadyExistException)1 LdapEntryNotFoundException (com.zimbra.cs.ldap.LdapException.LdapEntryNotFoundException)1 ZAttributes (com.zimbra.cs.ldap.ZAttributes)1 ZLdapFilter (com.zimbra.cs.ldap.ZLdapFilter)1 ZSearchResultEntry (com.zimbra.cs.ldap.ZSearchResultEntry)1 ZSearchResultEnumeration (com.zimbra.cs.ldap.ZSearchResultEnumeration)1 ArrayList (java.util.ArrayList)1