Spring LDAP querybuilder PartialResultException

拈花ヽ惹草 提交于 2019-12-05 20:46:02

You write in question's comment that changing port helps. But changing port doesn't solve this problem. Port 3268 points to Active Directory special place - Global Catalog. There is set of all object - but each of them has only small subset of attributes (for example distinguishedName, cn, sAMAccountName...). So - it works until you don't need more specific attributes.

Problem analysis

The exception occurs because AD, as the result of your query, returns referral objects:

[Active Directory] (...) generate referrals in response to queries that request data about objects that exist in the forest, but not contained on the directory server handling the request. These are called internal cross references, because they refer to domains, schema, and configuration containers within the forest.

And if referral chasing is disabled:

If referral chasing is not enabled and a subtree search is performed, the search will return all objects within the specified domain that meet the search criteria. The search will also return referrals to any subordinate domains that are direct descendants of the directory server domain. The client must resolve the referrals by binding to the path specified by the referral and submitting another query.

You can enable referral chasing, but it cost - it slow down application - you can read about this here. And I think it is not necessary in most cases.

Solution 1:

Sometimes the sufficient solution is to assign more specific baseDN - ctxSrc.setBase() method in your question. Maybe all your users are inside inner path e.g "ou=user,dc=department,dc=test,dc=com".

Read more in this answer.

Solution 2:

In Spring LdapTemplate you can also ignore this exception with method setIgnorePartialResultException():

ldapTemplate.setIgnorePartialResultException(true);

Read more in this answer.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!