【问题标题】:Spring Embedded ServerSpring 嵌入式服务器
【发布时间】:2011-03-02 06:08:20
【问题描述】:

我正在使用 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)

有什么想法吗? 提前致谢!

【问题讨论】:

    标签: spring ldap spring-security apacheds


    【解决方案1】:

    首先,我假设您的 LDIF 文件实际上分为几行,如下所示:

    dn: cn=The Postmaster,dc=example,dc=com
    objectClass: organizationalRole
    cn: The Postmaster
    

    ...否则你甚至不会达到你现在的水平。

    但要回答您的问题,错误的发生是因为您试图将某些内容(在本例中为组织角色)添加到不存在的上下文(即“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 对此进行了测试。

    附言发布到 StackOverflow 时,请将您的代码、堆栈跟踪、测试数据等格式化为代码(例如,在编辑模式下,突出显示相关文本并单击“代码示例”按钮)。它使您的帖子更具可读性,因此人们更有可能为您提供帮助。

    【讨论】:

      【解决方案2】:

      我遇到了同样的问题。解决方案是在 Spring Security 中添加正确的上下文作为 ldap-server 标记的“根”属性。 在你的情况下:

      <security:ldap-server ldif="classpath:foo.ldif"  root="dc=example,dc=com"/>
      

      【讨论】:

        猜你喜欢
        • 2015-06-27
        • 1970-01-01
        • 1970-01-01
        • 2019-10-11
        • 2015-09-30
        • 2021-05-18
        • 2023-04-08
        • 1970-01-01
        • 2014-06-04
        相关资源
        最近更新 更多