/** * Executes a {@link DeleteOperation} on the supplied DN. * * @param dn to delete * * @return response for the delete operation * * @throws LdapException if the operation fails */ @Nonnull private Response<Void> delete(@Nonnull final String dn) throws LdapException { Connection conn = null; try { conn = connectionFactory.getConnection(); final DeleteOperation delete = new DeleteOperation(conn); return delete.execute(new DeleteRequest(dn)); } finally { conn.close(); } }
/** * Executes a {@link DeleteOperation} for the supplied entry. * * @param request merge request * @param entry to delete from the LDAP * * @return response of the delete operation * * @throws LdapException if an error occurs executing the deleting operation */ protected Response<Void> delete(final MergeRequest request, final LdapEntry entry) throws LdapException { Response<Void> response; final DeleteOperation delete = new DeleteOperation(getConnection()); response = delete.execute(new DeleteRequest(entry.getDn())); logger.info("delete entry {} for request {}", entry, request); return response; } }
/** * Executes the ldap delete operation. * * @param cf connection factory. * @param entryDns to delete * * @return status code * * @throws Exception on any LDAP search error */ protected int delete(final ConnectionFactory cf, final String[] entryDns) throws Exception { final Connection conn = cf.getConnection(); conn.open(); for (String dn : entryDns) { final DeleteOperation op = new DeleteOperation(conn); op.execute(new DeleteRequest(dn)); System.out.println(String.format("Deleted entry: %s", dn)); } conn.close(); return 0; }
/** * Executes a {@link DeleteOperation} for the supplied entry. * * @param request merge request * @param entry to delete from the LDAP * * @return response of the delete operation * * @throws LdapException if an error occurs executing the deleting operation */ protected Response<Void> delete(final MergeRequest request, final LdapEntry entry) throws LdapException { final Response<Void> response; final DeleteOperation delete = new DeleteOperation(getConnection()); response = delete.execute(new DeleteRequest(entry.getDn())); logger.info("delete entry {} for request {}", entry, request); return response; } }
/** * Executes the ldap delete operation. * * @param cf connection factory. * @param entryDns to delete * * @return status code * * @throws Exception on any LDAP search error */ protected int delete(final ConnectionFactory cf, final String[] entryDns) throws Exception { final Connection conn = cf.getConnection(); conn.open(); for (String dn : entryDns) { final DeleteOperation op = new DeleteOperation(conn); op.execute(new DeleteRequest(dn)); System.out.println(String.format("Deleted entry: %s", dn)); } conn.close(); return 0; }
/** * Executes a {@link DeleteOperation} for the supplied entry. * * @param request merge request * @param entry to delete from the LDAP * * @return response of the delete operation * * @throws LdapException if an error occurs executing the deleting operation */ protected Response<Void> delete(final MergeRequest request, final LdapEntry entry) throws LdapException { final Response<Void> response; final DeleteOperation delete = new DeleteOperation(getConnection()); response = delete.execute(new DeleteRequest(entry.getDn())); logger.info("delete entry {} for request {}", entry, request); return response; } }
/** * Executes the ldap delete operation. * * @param cf connection factory. * @param entryDns to delete * * @return status code * * @throws Exception on any LDAP search error */ protected int delete(final ConnectionFactory cf, final String[] entryDns) throws Exception { final Connection conn = cf.getConnection(); conn.open(); for (String dn : entryDns) { final DeleteOperation op = new DeleteOperation(conn); op.execute(new DeleteRequest(dn)); System.out.println(String.format("Deleted entry: %s", dn)); } conn.close(); return 0; }
@Override public Response<Void> delete(final T object) throws LdapException { final String dn = getLdapEntryMapper().mapDn(object); final DeleteRequest request = new DeleteRequest(dn); try (Connection conn = getConnectionFactory().getConnection()) { conn.open(); final DeleteOperation delete = new DeleteOperation(conn); return delete.execute(request); } } }
/** * Execute delete operation boolean. * * @param connectionFactory the connection factory * @param entry the entry * @return the boolean * @throws LdapException the ldap exception */ public static boolean executeDeleteOperation(final ConnectionFactory connectionFactory, final LdapEntry entry) throws LdapException { try (Connection connection = createConnection(connectionFactory)) { final DeleteOperation delete = new DeleteOperation(connection); final DeleteRequest request = new DeleteRequest(entry.getDn()); request.setReferralHandler(new DeleteReferralHandler()); final Response<Void> res = delete.execute(request); return res.getResultCode() == ResultCode.SUCCESS; } catch (final LdapException e) { LOGGER.error(e.getMessage(), e); } return false; } }
@Override protected void deleteById(final String id) { Connection connection = null; try { connection = connectionFactory.getConnection(); connection.open(); final DeleteOperation delete = new DeleteOperation(connection); delete.execute(new DeleteRequest(getIdAttribute() + "=" + id + "," + usersDn)); } catch (final LdapException e) { throw new TechnicalException(e); } finally { if (connection != null) { connection.close(); } } }
@Override protected DeleteRequest createReferralRequest(final DeleteRequest request, final LdapURL url) { final DeleteRequest referralRequest = new DeleteRequest(); referralRequest.setControls(request.getControls()); referralRequest.setIntermediateResponseHandlers(request.getIntermediateResponseHandlers()); referralRequest.setReferralHandler( new DeleteReferralHandler(getReferralLimit(), getReferralDepth() + 1, getReferralConnectionFactory())); if (!url.getEntry().isDefaultBaseDn()) { referralRequest.setDn(url.getEntry().getBaseDn()); } else { referralRequest.setDn(request.getDn()); } return referralRequest; }
@Override protected DeleteRequest createReferralRequest(final DeleteRequest request, final LdapURL url) { final DeleteRequest referralRequest = new DeleteRequest(); referralRequest.setControls(request.getControls()); referralRequest.setIntermediateResponseHandlers(request.getIntermediateResponseHandlers()); referralRequest.setReferralHandler( new DeleteReferralHandler(getReferralLimit(), getReferralDepth() + 1, getReferralConnectionFactory())); if (!url.getEntry().isDefaultBaseDn()) { referralRequest.setDn(url.getEntry().getBaseDn()); } else { referralRequest.setDn(request.getDn()); } return referralRequest; }
@Override protected DeleteRequest createReferralRequest(final DeleteRequest request, final LdapURL url) { final DeleteRequest referralRequest = new DeleteRequest(); referralRequest.setControls(request.getControls()); referralRequest.setIntermediateResponseHandlers(request.getIntermediateResponseHandlers()); referralRequest.setReferralHandler( new DeleteReferralHandler(getReferralLimit(), getReferralDepth() + 1, getReferralConnectionFactory())); if (!url.getEntry().isDefaultBaseDn()) { referralRequest.setDn(url.getEntry().getBaseDn()); } else { referralRequest.setDn(request.getDn()); } return referralRequest; }