Search in sources :

Example 1 with DeleteReferralHandler

use of org.ldaptive.referral.DeleteReferralHandler in project cas by apereo.

the class LdapUtils method executeDeleteOperation.

/**
     * Execute delete operation boolean.
     *
     * @param connectionFactory the connection factory
     * @param entry             the entry
     * @return true/false
     * @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;
}
Also used : DeleteOperation(org.ldaptive.DeleteOperation) Connection(org.ldaptive.Connection) DeleteRequest(org.ldaptive.DeleteRequest) DeleteReferralHandler(org.ldaptive.referral.DeleteReferralHandler) LdapException(org.ldaptive.LdapException)

Aggregations

Connection (org.ldaptive.Connection)1 DeleteOperation (org.ldaptive.DeleteOperation)1 DeleteRequest (org.ldaptive.DeleteRequest)1 LdapException (org.ldaptive.LdapException)1 DeleteReferralHandler (org.ldaptive.referral.DeleteReferralHandler)1