use of com.zimbra.cs.ldap.ZLdapContext in project zm-mailbox by Zimbra.
the class ZLdapHelper method deleteEntry.
@Override
public void deleteEntry(String dn, LdapUsage ldapUsage) throws ServiceException {
ZLdapContext zlc = null;
try {
zlc = LdapClient.getContext(LdapServerType.MASTER, ldapUsage);
zlc.deleteEntry(dn);
} finally {
LdapClient.closeContext(zlc);
}
}
use of com.zimbra.cs.ldap.ZLdapContext in project zm-mailbox by Zimbra.
the class ZLdapHelper method modifyEntry.
@Override
public void modifyEntry(String dn, Map<String, ? extends Object> attrs, Entry entry, LdapUsage ldapUsage) throws ServiceException {
ZLdapContext zlc = null;
try {
zlc = LdapClient.getContext(LdapServerType.MASTER, ldapUsage);
modifyAttrs(zlc, dn, attrs, entry);
} finally {
LdapClient.closeContext(zlc);
}
}
use of com.zimbra.cs.ldap.ZLdapContext 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);
}
}
use of com.zimbra.cs.ldap.ZLdapContext in project zm-mailbox by Zimbra.
the class LdapProvisioning method createZimlet.
@Override
public Zimlet createZimlet(String name, Map<String, Object> zimletAttrs) throws ServiceException {
name = name.toLowerCase().trim();
CallbackContext callbackContext = new CallbackContext(CallbackContext.Op.CREATE);
AttributeManager.getInstance().preModify(zimletAttrs, null, callbackContext, true);
ZLdapContext zlc = null;
try {
zlc = LdapClient.getContext(LdapServerType.MASTER, LdapUsage.CREATE_ZIMLET);
String hasKeyword = LdapConstants.LDAP_FALSE;
if (zimletAttrs.containsKey(A_zimbraZimletKeyword)) {
hasKeyword = ProvisioningConstants.TRUE;
}
ZMutableEntry entry = LdapClient.createMutableEntry();
entry.mapToAttrs(zimletAttrs);
entry.setAttr(A_objectClass, "zimbraZimletEntry");
entry.setAttr(A_zimbraZimletEnabled, ProvisioningConstants.FALSE);
entry.setAttr(A_zimbraZimletIndexingEnabled, hasKeyword);
entry.setAttr(A_zimbraCreateTimestamp, LdapDateUtil.toGeneralizedTime(new Date()));
String dn = mDIT.zimletNameToDN(name);
entry.setDN(dn);
zlc.createEntry(entry);
Zimlet zimlet = lookupZimlet(name, zlc);
AttributeManager.getInstance().postModify(zimletAttrs, zimlet, callbackContext);
return zimlet;
} catch (LdapEntryAlreadyExistException nabe) {
throw AccountServiceException.ZIMLET_EXISTS(name);
} catch (LdapException e) {
throw e;
} catch (AccountServiceException e) {
throw e;
} catch (ServiceException e) {
throw ServiceException.FAILURE("unable to create zimlet: " + name, e);
} finally {
LdapClient.closeContext(zlc);
}
}
use of com.zimbra.cs.ldap.ZLdapContext in project zm-mailbox by Zimbra.
the class LdapProvisioning method searchZimbraLdap.
private void searchZimbraLdap(String base, String query, String[] returnAttrs, boolean useMaster, SearchLdapVisitor visitor) throws ServiceException {
SearchLdapOptions searchOptions = new SearchLdapOptions(base, query, returnAttrs, SearchLdapOptions.SIZE_UNLIMITED, null, ZSearchScope.SEARCH_SCOPE_SUBTREE, visitor);
ZLdapContext zlc = null;
try {
zlc = LdapClient.getContext(LdapServerType.get(useMaster), LdapUsage.SEARCH);
zlc.searchPaged(searchOptions);
} finally {
LdapClient.closeContext(zlc);
}
}
Aggregations