【问题标题】:Spring LDAP Base ConfigurationSpring LDAP 基本配置
【发布时间】:2017-08-12 05:25:16
【问题描述】:

我的目录结构为

ou=studentBase,dc=example,dc=com

在我的安全 XML 中有

<bean id="contextSource" class="org.springframework.ldap.core.support.LdapContextSource">
  <property name="base" value="ou=studentBase,dc=example,dc=com" />
  <property name="url" value="ldaps://serveraddress:port" />
  <property name="userDn" value="username" />
  <property name="password" value="pwd" />
</bean>

我想查询容器对象的属性

cn=container,cn=schema,cn=configuration,dc=example,dc=com

当我将基数设置为

进行搜索时
cn=container,cn=schema,cn=configuration,dc=example,dc=com

ldapTemplate.search(base, filter.encode(), new AttributesMapper()){
}

我收到一个错误

org.springframework.ldap.NameNotFoundException: [LDAP: error code 32 - 0000208D: NameErr: DSID-03100238, problem 2001 (NO_OBJECT), data 0, best match of: 'ou=studentBase,dc=example,dc=com']; nested exception is
javax.naming.NameNotFoundException: [LDAP: error code 32 - 0000208D: NameErr: DSID-03100238, problem 2001 (NO_OBJECT), data 0, best match of:
    'ou=studentBase,dc=example,dc=com']; remaining name cn=container,cn=schema,cn=configuration,dc=example,dc=com

问题是我无法更改基础以搜索除我放入 xml 配置文件中的基础之外的任何内容。我也试过SearchControls 并且遇到了同样的问题。如何在不同的基础上进行搜索。我已经编写了整个应用程序,无法解决这个问题。

【问题讨论】:

    标签: java spring spring-mvc ldap jndi


    【解决方案1】:

    您需要添加另一个contextSource 进行配置查找:

    <bean id="schemaContextSource" class="org.springframework.ldap.core.support.LdapContextSource">
      <property name="base" value="cn=configuration,dc=example,dc=com" />
      <property name="url" value="ldaps://serveraddress:port" />
      <property name="userDn" value="username" />
      <property name="password" value="pwd" />
    </bean>
    

    并确保您使用的userDN 有权查看/更改在线配置,出于安全原因,该用户不应contextSource 的用户相同。

    但我觉得很奇怪一个应用程序应该这样做。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-10-20
      • 2011-10-08
      • 1970-01-01
      • 1970-01-01
      • 2014-10-27
      • 2014-12-30
      • 2019-04-03
      相关资源
      最近更新 更多