簡體   English   中英

Spring LDAP基本配置

[英]Spring LDAP Base Configuration

我有目錄結構

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 ,並遇到了同樣的問題。 如何在不同的基礎上進行搜索。 我已經編寫了整個應用程序,無法解決這個問題。

您需要添加另一個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 ,出於安全原因。

但是我發現應用程序想要這樣做很奇怪。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM