我正在使用spring 3.0.2和ApacheDS 1.5.5,我正在尝试使用以下命令运行嵌入式服务器:
<ldap-server ldif="classpath:conf/users.ldif" port="39999"/>
user.s.ldif文件的内容为:
dn: cn=The Postmaster,dc=example,dc=com
objectClass: organizationalRole
cn: The Postmaster
但我总是得到这个错误:
16566 [main] INFO org.apache.directory.server.protocol.shared.store. LdifFileLoader - Could not create entry ClientEntry
dn: cn=The Postmaster,dc=example,dc=com
objectclass: organizationalRole
cn: The Postmaster
org.apache.directory.shared.ldap.exception.LdapNam eNotFoundException: Cannot find a partition for 2.5.4.3=the postmaster,0.9.2342.19200300.100.1.25=example,0.9.2342.19200300.100.1.25=com
at org.apache.directory.server.core.partition.DefaultPartitionNexus.getPartition(DefaultPartitionNexus. java:1082)
at org.apache.directory.server.core.partition.DefaultPartitionNexus.hasEntry(DefaultPartitionNexus.java :1037)
at org.apache.directory.server.core.interceptor.InterceptorChain$1.hasEntry(InterceptorChain.java:167)
at org.apache.directory.server.core.interceptor.InterceptorChain$Entry$1.hasEntry(InterceptorChain.java :1300)
at org.apache.directory.server.core.interceptor.BaseInterceptor.hasEntry(BaseInterceptor.java:159)
at org.apache.directory.server.core.interceptor.InterceptorChain$Entry$1.hasEntry(InterceptorChain.java :1300)
at org.apache.directory.server.core.interceptor.BaseInterceptor.hasEntry(BaseInterceptor.java:159)
at org.apache.directory.server.core.interceptor.InterceptorChain$Entry$1.hasEntry(InterceptorChain.java :1300)
at org.apache.directory.server.core.exception.ExceptionInterceptor.add(ExceptionInterceptor.java:154)
at org.apache.directory.server.core.interceptor.InterceptorChain$Entry$1.add(InterceptorChain.java:1196 )
at org.apache.directory.server.core.referral.ReferralInterceptor.add(ReferralInterceptor.java:251)
at org.apache.directory.server.core.interceptor.InterceptorChain$Entry$1.add(InterceptorChain.java:1196 )
at org.apache.directory.server.core.authn.AuthenticationInterceptor.add(AuthenticationInterceptor.java: 212)
at org.apache.directory.server.core.interceptor.InterceptorChain$Entry$1.add(InterceptorChain.java:1196 )
at org.apache.directory.server.core.normalization.NormalizationInterceptor.add(NormalizationInterceptor .java:126)
at org.apache.directory.server.core.interceptor.InterceptorChain.add(InterceptorChain.java:756)
at org.apache.directory.server.core.DefaultOperationManager.add(DefaultOperationManager.java:260)
at org.apache.directory.server.core.DefaultCoreSession.add(DefaultCoreSession.java:145)
at org.apache.directory.server.core.DefaultCoreSession.add(DefaultCoreSession.java:122)
at org.apache.directory.server.protocol.shared.store.LdifFileLoader.execute(LdifFileLoader.java:204)
at org.springframework.security.ldap.server.ApacheDSContainer.importLdifs(ApacheDSContainer.java:237)
at org.springframework.security.ldap.server.ApacheDSContainer.start(ApacheDSContainer.java:189)
任何想法? 提前致谢!
答案 0 :(得分:6)
我遇到了同样的问题。解决方案是在Spring Security中添加正确的上下文作为ldap-server标记的“root”-Attribute。 在你的情况下:
<security:ldap-server ldif="classpath:foo.ldif" root="dc=example,dc=com"/>
答案 1 :(得分:0)
首先,我假设您的LDIF文件实际上是分成几行,如下所示:
dn: cn=The Postmaster,dc=example,dc=com
objectClass: organizationalRole
cn: The Postmaster
......否则你甚至不会得到你所能达到的目标。
但是要回答你的问题,错误的发生是因为你试图将一些东西(在这种情况下是一个organizationalRole)添加到一个不存在的上下文(即“dc = example,dc = com”)。尝试将该上下文更改为确实存在的上下文。我不能说没有看到你的Spring bean文件会是什么,但默认情况下,Spring的嵌入式LDAP服务器使用“dc = springframework,dc = org”的根,所以尝试将LDIF文件更改为:
dn: cn=The Postmaster,dc=springframework,dc=org
objectClass: organizationalRole
cn: The Postmaster
我使用Spring 3.0.3.RELEASE和ApacheDS 1.5.5进行了测试。
P.S。在发布到StackOverflow时,请将代码,堆栈跟踪,测试数据等格式化为代码(例如,在编辑模式下,突出显示相关文本并单击“代码示例”按钮)。它使您的帖子更具可读性,因此人们更有可能帮助您。