LDAP整个子树副本

时间:2008-09-30 09:56:12

标签: ldap copy subtree

我实际上是这个论坛的新手,我一直试着找几个简单的方法将整个LDAP子树复制到另一棵树上。由于我找不到任何有用的东西,我想在这里提出一个问题。有没有人知道如何以编程方式执行此操作?

对于正常操作,如添加,删除,搜索,我一直在使用Spring LDAP。

非常感谢!

3 个答案:

答案 0 :(得分:1)

我实际上并不了解Spring LDAP,但如果您的LDAP接口没有为移动/重命名或复制整个子树提供任何高级抽象,则必须递归地移动/重命名或复制所有子树节点。 LDAP API不直接提供此类选项。

以下是伪代码:

function copySubtree(oldDn, newDn)
{
    copyNode(oldDn, newDn); // the new node will be created here
    if (nodeHasChildren(oldDn) { 
        foreach (nodeGetChildren(oldDn) as childDn) {
            childRdn=getRdn(childDn); // we have to get the 'local' part, the so called RDN 
            newChildDn=childRdn + ',' + newDn; // the new DN will be the old RDN concatenated with the new parent's DN
            copySubtree(childDn, newChildDn); // call this function recursively
        }  
    }
}

答案 1 :(得分:1)

将其转储为LDIF,通过搜索&编辑DN。替换(或通过脚本),并导入新的LDIF。

Spring可能不是这样做的工具。是否有必要使用Spring操作目录?我认为OpenLDAP的ldapsearch和ldapadd应该可以对任何服务器起作用,并且它们将转储/加载LDIF。

答案 2 :(得分:0)

请注意,密码复制起来很棘手。您可能会也可能无法通过LDAP API读取它们。这将取决于你使用它的LDAP实现。

因此,复制到新位置可能无法获得您想要或需要的所有内容。

相关问题