簡體   English   中英

Spring LDAP LDAP:錯誤代碼 32 - 0000208D

[英]Spring Ldap LDAP: error code 32 - 0000208D

我正在開發使用 LDAP 進行身份驗證的應用程序。 正在使用 spring LDAP 模板進行身份驗證,但收到以下響應

{
    "message": "[LDAP: error code 32 - 0000208D: NameErr: DSID-031001E5, problem 2001 (NO_OBJECT), data 0, best match of:\n\t''\n\u0000]; nested exception is javax.naming.NameNotFoundException: [LDAP: error code 32 - 0000208D: NameErr: DSID-031001E5, problem 2001 (NO_OBJECT), data 0, best match of:\n\t''\n\u0000]; remaining name '/'"
}

下面是spring的配置

<beans:bean id="contextSource"
    class="org.springframework.ldap.core.support.LdapContextSource">
    <beans:property name="base" value="" />
    <beans:property name="url" value="<LDAP-URL>" />
    <beans:property name="userDn" value="<USER-DN>" />
    <beans:property name="password" value="<PASSWORD>" />
</beans:bean>

<beans:bean id="ldapTemplate" class="org.springframework.ldap.core.LdapTemplate">
    <beans:constructor-arg ref="contextSource" />
</beans:bean>

Java代碼:

AndFilter filter = new AndFilter();
filter.and(new EqualsFilter("objectclass", "person")).and(new       EqualsFilter("sAMAccountName", username));
boolean result = ldapTemplate.authenticate(LdapUtils.emptyLdapName(),               filter.toString(), password);

我是 LDAP 的新手,任何幫助或示例都非常棒。

當您已經設置了基數時,您不需要在進一步的操作中指定完整的 dn。 你確定你有正確的服務器規格嗎? 錯誤 32 通常是搞砸了前綴或目錄配置!

根據之前的正確答案,searchBase 必須為空。 我的正確過濾器是:

FilterBasedLdapUserSearch userSearch = new FilterBasedLdapUserSearch("", "(&(CN={0})(memberOf=cn=Group-BioBank,OU=HyperV,OU=Services,DC=bob,DC=uk))", contextSource);

這個過濾器就像一個魅力。 (Spring4.x)

過濾器解釋: https : //confluence.atlassian.com/kb/how-to-write-ldap-search-filters-7924​​96933.html

暫無
暫無

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

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