如何通过unboundid中的单个ldap请求删除多个条目?

问题描述 投票:0回答:1

我调查了https://docs.ldap.com/ldap-sdk/docs/javadoc/com/unboundid/ldap/sdk/DeleteRequest.html

并且看起来它只允许删除单个条目(如果传递了删除子树控件,则带有子树)。

在我的用例中,我想删除多个同级条目,可能有数百个同级条目。我不想进行数百次 ldap 调用。有没有办法通过一次调用来完成这项工作?

active-directory ldap samba unboundid-ldap-sdk samba-dc
1个回答
0
投票

我认为你会使用

MultiUpdateExtendedRequest
。根据文档中的示例,它可能看起来像这样:

 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.
 }
© www.soinside.com 2019 - 2024. All rights reserved.