如何使用 unboundid-ldap-sdp 导入 ldif 文件?

2024-05-06

我从 LDAP 服务器导出了以下 ldif 文件,现在尝试导入它,以便可以复制从中导出它的目录:

dn: cn=MYCOMPANY Users,dc=mycompany,dc=com
changetype: add
objectClass: posixGroup
objectClass: top
cn: MYCOMPANY Users
gidNumber: 1001

dn: cn=jim smith,cn=MYCOMPANY Users,dc=mycompany,dc=com
objectClass: inetOrgPerson
objectClass: posixAccount
objectClass: top
givenName: jim
cn: jim smith
sn: smith
gidNumber: 1000
homeDirectory: /home/users/arolls
uid: jsmith
uidNumber: 1038
userPassword: {MD5}X03MO1qnZdYdgyfeuILPmQ==

dn: cn=dave jones,cn=MYCOMPANY Users,dc=mycompany,dc=com
objectClass: inetOrgPerson
objectClass: posixAccount
objectClass: top
givenName: dave
userPassword: {MD5}FhCDh0PMkOPk/dp0goLZuA==
loginShell: /bin/sh
cn: dave jones
sn: dave
gidNumber: 1000
homeDirectory: /home/users/dave
uid: dave
uidNumber: 1006

我正在尝试使用导入它

LDIFReader r = new LDIFReader(resourceAsStream);
LDIFChangeRecord readEntry = null;
while ((readEntry = r.readChangeRecord()) != null) {
  readEntry.processChange(server);
}

我收到以下错误,有人知道我做错了什么吗?

LDAPException(resultCode=65 (object class violation), errorMessage='Unable to add entry 'cn=MYCOMPANY Users,dc=mycompany,dc=com' because it violates the provided schema: The entry contains object class posixGroup which is not defined in the schema. The entry contains attribute cn which is not allowed by its object classes and/or DIT content rule. The entry contains attribute gidNumber which is not defined in the schema. The entry's RDN contains attribute cn which is not allowed to be included in the entry.', diagnosticMessage='Unable to add entry 'cn=MYCOMPANY Users,dc=mycompany,dc=com' because it violates the provided schema: The entry contains object class posixGroup which is not defined in the schema. The entry contains attribute cn which is not allowed by its object classes and/or DIT content rule. The entry contains attribute gidNumber which is not defined in the schema. The entry's RDN contains attribute cn which is not allowed to be included in the entry.')

at com.unboundid.ldap.listener.InMemoryDirectoryServer.add(InMemoryDirectoryServer.java:1382)
at com.unboundid.ldif.LDIFAddChangeRecord.processChange(LDIFAddChangeRecord.java:213)
at com.github.trevershick.test.ldap.LdapServerResource.loadLdifFiles(LdapServerResource.java:156)
at com.github.trevershick.test.ldap.LdapServerResource.start(LdapServerResource.java:81)
at org.rory.util.services.ldap.TestLDAPAuthUIUtilUsingInMemoryLdapServer.startup(TestLDAPAuthUIUtilUsingInMemoryLdapServer.java:42)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
java.lang.NullPointerException
at org.rory.util.services.ldap.TestLDAPAuthUIUtilUsingInMemoryLdapServer.shutdown(TestLDAPAuthUIUtilUsingInMemoryLdapServer.java:47)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)

非常感谢!


感谢尼尔,让这个工作成功了https://sourceforge.net/p/ldap-sdk/discussion/1001257/thread/08ceb8da/?limit=25#65b0 https://sourceforge.net/p/ldap-sdk/discussion/1001257/thread/08ceb8da/?limit=25#65b0.

具体来说,我需要做两件事:

  1. 通过以下方式禁用模式检查:

InMemoryDirectoryServerConfig.setSchema(null)

  1. 将以下 4 行添加到 ldif 顶部:

dn: dc=我的公司,dc=com

对象类别:顶部

对象类:域

DC:我的公司

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

如何使用 unboundid-ldap-sdp 导入 ldif 文件? 的相关文章

  • 无法从 java 发送 48681 字节消息以保护 wcf 服务

    我必须使用相互身份验证从 java 调用安全的 WCF 服务 一切工作正常 除了我无法发送大小超过 48680 字节的消息 因此 48680 字节的消息已成功发送 但 48681 字节的消息未成功发送 并且 java 应用程序因读取超时异常
  • 如何在 NetBeans 中以调试模式单步执行已实现的方法?

    我有课XImpl java它实现了一个接口X java 以及所有它的方法 我调试项目 在执行流程中遇到一个方法X processSomeValue 现在 当我尝试进入该方法时processSomeValue 我无能为力 有什么办法可以让我进
  • 什么是“非阻塞”并发?它与普通并发有何不同?

    什么是 非阻塞 并发 它与使用线程的普通并发有何不同 为什么不在所有需要并发的场景中都使用非阻塞并发呢 使用非阻塞并发有开销吗 我听说Java中可以实现非阻塞并发 我们是否应该在特定场景下使用此功能 将这些方法之一与集合一起使用是否有区别或
  • Java 延迟/等待

    如何将 while 循环延迟到 1 秒间隔 而不减慢其运行的整个代码 计算机的速度到一秒延迟 只是一个小循环 Thread sleep 1000 do nothing for 1000 miliseconds 1 second
  • java.io.IOException: EnsureRemaining: 仅剩余 0 个字节,尝试读取 1

    我在 giraph 中的自定义类方面遇到一些问题 我制作了 VertexInput 和 Output 格式 但总是收到以下错误 java io IOException ensureRemaining Only bytes remaining
  • 使用 Bouncy Castle 重建 ED25519 按键 (Java)

    Bouncy Castle 的最新 测试版 版本 bcprov jdk15on 161b20 jar 支持 ED25519 和 ED448 EC 加密以进行签名 我设置了这个完整的工作示例 它按预期工作 我的问题 我是否正确重建了私钥和公钥
  • Java生成范围内不重复的随机数

    我想生成 1 到 4 范围内的随机数 包括 4 这是我的代码 int num r nextInt 4 1 r is instance of Random 但是 我在循环中运行上述代码 并且不想重复随机数 现在发生的事情我经常得到 1 1 1
  • 使android listview布局可滚动

    我有一个 xml 文件 其布局为 ASCII 形式 ImageView TextView List
  • 抽象方法实现与抽象方法重写。这两个对于抽象类意味着相同吗?

    我几乎要采取Java SE 8 程序员我 exam 1Z0 808 我正在使用这个学习指南 https www selikoff net java oca 8 programmer i study guide https www selik
  • 使用枚举变量切换字符串

    我有一个具有不同值的枚举 并且想要切换字符串变量 现在 我在尝试将枚举值转换为字符串 可以用作大小写常量 时遇到了困难 我最好的尝试是将枚举转换为字符串数组 但开关似乎不接受数组值作为大小写常量 IntelliJ 说 需要恒定的表达 Enu
  • 无法在android中使用retrofit发出@Post请求

    我正在学习如何在 android 中使用改造 但是每当我尝试从互联网检索数据时 我的应用程序不会返回任何内容我的响应没有成功 我不知道如何修复当前我正在尝试发布的错误并使用此 URL 检索数据https jsonplaceholder ty
  • 如何在不打开浏览器的情况下查看 Android 应用程序中的网页?

    嘿 我正在开发一个 Android 应用程序 我想连接到该应用程序内的网络 不过 我在某种程度上尝试过 WebView 但它在我的目录中显示的文件很好 但当连接到 google com 时 它显示错误 然后我添加了这个文件
  • 如何告诉 Eclipse 忽略 Ant build.xml 中的错误?

    我有一个使用 Maven 构建的 Eclipse 项目 并且我在 Eclipse 中使用 m2eclipse 插件来获得 Maven 支持 然而这个项目还包含一个build xml它并不用于实际构建项目 而只是用于编写脚本功能 作为项目开发
  • JList 类型不采用参数类型

    当我尝试编译一些代码时 我不断收到这些错误 CCC java 21 type javax swing JList does not take parameters JList
  • 有没有办法防止 Spring Boot 覆盖 bean?

    与春天的抽象可刷新应用程序上下文 http docs spring io spring docs current javadoc api org springframework context support AbstractRefresh
  • Android中计算两个时间之间的差异

    我有两个字符串变量 例如 StartTime 和 EndTime 我需要通过用 StartTime 减去 EndTime 来计算 TotalTime StartTime和EndTime的格式如下 StartTime 08 00 AM End
  • 从 Brixton.RC1 开始的 ZuulProxy 未传递授权标头

    从 Spring Cloud 切换时Brixton M5 to Brixton RC1我的 ZuulProxy 不再通过Authorization标头下游到我的代理服务 我的设置中有各种各样的角色 但大多数都相当简单 Authorizati
  • 无法验证 serde:org.openx.data.jsonserde.jsonserde

    我编写了这个查询来在配置单元上创建一个表 我的数据最初是 json 格式 所以我已经下载并构建了 serde 并添加了它运行所需的所有 jar 但我收到以下错误 FAILED Execution Error return code 1 fr
  • 尝试接收 UDP 多播时出现空指针异常

    在尝试了几次让简单的 UDP 多播接收器工作后 我感到很困惑 在我自己的代码无法按预期工作后 我尝试了 vertx 文档中发布的确切示例 DatagramSocket socket vertx createDatagramSocket ne
  • 如何在Java中添加两个“卡”的值?

    我正在开发一个项目来模拟二十一点游戏中的第一笔交易 到目前为止 程序创建了两张随机等级 ACE 到 KING 和随机花色的牌 我正在努力创建一个切换表或 if else 梯形图 将两张卡的附加值分配为可变分数 下面的代码从概念上代表了我想要

随机推荐