Menu

How to copy a branch?

HY.Zou
2014-08-14
2014-08-14
  • HY.Zou

    HY.Zou - 2014-08-14

    I want to copy and paste a entry with all its sub-entries to a new place. is there a build-in API which I can use to do this?
    another question
    Does this package provides APIs to manage schema?

     
  • Neil Wilson

    Neil Wilson - 2014-08-14

    LDAP doesn't provide any kind of direct copy operation, so the only standard way to go about this would be to read an entry that you want to copy, alter it as appropriate (e.g., to at least specify the new DN), and add the new entry to the server. If you want to do this for an entire subtree, then you'll need to do it an entry at a time, starting with parents and working your way down toward the leaf entries.

    If you want to move entries from one part of the DIT to another, then the modify DN operation can be used to accomplish that (although some servers do not support that for subtree moves). However, copying entries can be much more problematic and there are some caveats that you need to be aware of.

    First, you should be wary when trying to copy operational attributes. Many operational attributes are only intended for use by the server itself and should not be directly manipulated by clients. In most servers, these attributes are marked NO-USER-MODIFICATION and the server should reject any request that attempts to write to them, but in general it is strongly recommended that you only try to write to user attributes unless you know of specific operational attributes that are safe to update.

    In addition, the server may be configured to enforce uniqueness for certain attributes. For example, directory servers are often configured to ensure that no two users can have the same username or email address. If this is the case, then you can't make a direct copy of a user entry because the attempt to add a second entry with the same username or email address as an existing entry will cause the new entry to be rejected.

    The com.unboundid.ldap.sdk.schema package provides support for interacting with the server schema. There are standards for interacting with the schema in a read-only manner, but not all servers support altering the schema over LDAP and of those that do they may not all support it in the same way. You should check the documentation for whatever server you're using to determine whether it supports online schema updates and the appropriate way to accomplish that for that type of server.

     
    • HY.Zou

      HY.Zou - 2014-08-14

      That is much useful for me. thank you very much for you kindly reply :)

       

Log in to post a comment.