I investigated https://docs.ldap.com/ldap-sdk/docs/javadoc/com/unboundid/ldap/sdk/DeleteRequest.html
and looks like it allows to remove only a single entry(with subtree if delete subtree control is passed).
In my use case I want to remove multiple sibling entries and it could be hundreds siblings. I don't want to make hundreds of ldap calls. Is there way to do the job using a single call ?
I think you'd use MultiUpdateExtendedRequest
. Based on the example that's in the documentation, it might look something like this:
MultiUpdateExtendedRequest multiUpdateRequest =
new MultiUpdateExtendedRequest(
MultiUpdateErrorBehavior.ABORT_ON_ERROR,
new DeleteRequest("cn=entry to delete,dc=example,dc=com");,
new DeleteRequest("cn=entry to delete2,dc=example,dc=com"););
MultiUpdateExtendedResult multiUpdateResult =
(MultiUpdateExtendedResult)
connection.processExtendedOperation(multiUpdateRequest);
if (multiUpdateResult.getResultCode() == ResultCode.SUCCESS)
{
// The server successfully processed the multi-update request, although
// this does not necessarily mean that any or all of the changes
// contained in it were successful. For that, we should look at the
// changes applied and/or results element of the response.
switch (multiUpdateResult.getChangesApplied())
{
case NONE:
// There were no changes applied. Based on the configuration of the
// request, this means that the attempt to create the user failed
// and there was no subsequent attempt to add that user to a group.
break;
case ALL:
// Both parts of the update succeeded. The user was created and
// successfully added to a group.
break;
case PARTIAL:
// At least one update succeeded, and at least one failed. Based on
// the configuration of the request, this means that the user was
// successfully created but not added to the target group.
break;
}
}
else
{
// The server encountered a failure while attempting to parse or process
// the multi-update operation itself and did not attempt to process any
// of the changes contained in the request.
}