java 带有 Active Directory PartialResultException 的 JNDI

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5505351/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-30 11:27:30  来源:igfitidea点击:

JNDI with Active Directory PartialResultException

javaactive-directoryldapjndi

提问by startoftext

I am basically walking the LDAP tree in Active Directory.

我基本上是在 Active Directory 中遍历 LDAP 树。

At each level I query for "(objectClass=*)". When I do this on the root eg "dc=example,dc=com"I get the exception below. This works fine on our other LDAP instances. For some reason only on our Active Directory server I get this exception. I also get the same exception when using JXplorer on our Active Directory server.

在每个级别,我查询"(objectClass=*)". 当我在根上执行此操作时,例如"dc=example,dc=com"我得到以下异常。这在我们的其他 LDAP 实例上运行良好。出于某种原因,仅在我们的 Active Directory 服务器上,我收到此异常。在我们的 Active Directory 服务器上使用 JXplorer 时,我也遇到了同样的异常。

From reading around online I found people saying you should turn on following, not sure what that means... So on my controls object (javax.naming.directory.SearchControls) that I pass with the query I call searchControls.setDerefLinkFlag(true). I also have tried setting it to falsewith the same result. Any a suggestions on what else could cause this? Maybe how I could fix it?

通过在线阅读,我发现有人说你应该打开关注,不知道这意味着什么......所以在我的控件对象 ( javax.naming.directory.SearchControls) 上,我通过我调用的查询传递searchControls.setDerefLinkFlag(true)。我也尝试将其设置false为相同的结果。关于还有什么可能导致这种情况的任何建议?也许我该如何解决?

Note: In this post I changed the baseDn from dc=<my company domain>to example for my companies privacy.

注意:在这篇文章中dc=<my company domain>,为了我公司的隐私,我将 baseDn 从示例更改为示例。

javax.naming.PartialResultException: Unprocessed Continuation Reference(s); remaining name 'dc=example,dc=com'
at com.sun.jndi.ldap.LdapCtx.processReturnCode(LdapCtx.java:2820)
at com.sun.jndi.ldap.LdapCtx.processReturnCode(LdapCtx.java:2794)
at com.sun.jndi.ldap.LdapCtx.searchAux(LdapCtx.java:1826)
at com.sun.jndi.ldap.LdapCtx.c_search(LdapCtx.java:1749)
at com.sun.jndi.toolkit.ctx.ComponentDirContext.p_search(ComponentDirContext.java:368)
at com.sun.jndi.toolkit.ctx.PartialCompositeDirContext.search(PartialCompositeDirContext.java:338)
at com.sun.jndi.toolkit.ctx.PartialCompositeDirContext.search(PartialCompositeDirContext.java:321)
at javax.naming.directory.InitialDirContext.search(InitialDirContext.java:248)
at com.motio.pi.gui.panels.useraccess.ldap.LDAPConnector.query(LDAPConnector.java:262)
at com.motio.pi.gui.selector.directory.CognosDirectoryBrowserController.expandCognosTreeNode(CognosDirectoryBrowserController.java:99)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.motio.pi.utils.PIThreadDelegate.run(PIThreadDelegate.java:54)
at java.lang.Thread.run(Thread.java:662)

回答by startoftext

So when I was creating my naming context with the method:

因此,当我使用该方法创建命名上下文时:

javax.naming.ldap.InitialLdapContext.InitialLdapContext(
   Hashtable<?, ?> environment, Control[] connCtls)

In the argument environmentthere is a property with the name Context.REFERRALand its value should be set to: follow. This was the setting that I needed.

在参数中environment有一个带有名称的属性,Context.REFERRAL其值应设置为:follow。这是我需要的设置。

回答by mertaksu

If you get an exception while referral usage in follow (for example: connection timed out) you can use referral ignore but you dont want to get partial exception you can use 3268 port number instead of 389 this port is using global catalog for ldap. You can find info from following link;

如果您在引用使用时遇到异常(例如:连接超时),您可以使用引用忽略,但您不想获得部分异常,您可以使用 3268 端口号而不是 389,此端口正在使用 ldap 的全局目录。您可以从以下链接中找到信息;

https://technet.microsoft.com/en-us/library/how-global-catalog-servers-work(v=ws.10).aspx

https://technet.microsoft.com/en-us/library/how-global-catalog-servers-work(v=ws.10).aspx