我基本上走在Active Directory中的LDAP树.
在每个级别,我查询"(objectClass=*)".当我在root上执行此操作时,例如,"dc=example,dc=com"我将获得以下异常.这适用于我们的其他LDAP实例.出于某种原因,仅在我们的Active Directory服务器上出现此异常.在Active Directory服务器上使用JXplorer时,我也会遇到相同的异常.
从网上阅读我发现有人说你应该打开跟随,不知道这意味着什么...所以在我javax.naming.directory.SearchControls通过我调用的查询传递的控件对象()上searchControls.setDerefLinkFlag(true).我也尝试过将其设置false为相同的结果.关于还有什么可能导致这个问题的任何建议?也许我怎么能解决它?
注意:在这篇文章中,我将baseDn更改dc=<my company domain>为我的公司隐私的示例.
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$1.run(PIThreadDelegate.java:54)
at java.lang.Thread.run(Thread.java:662)
Run Code Online (Sandbox Code Playgroud) 我正在尝试从LDAP服务器中获取所有用户,并从基础上进行搜索,这是我的代码:
public LdapTemplate ldapTemplate() {
LdapContextSource ctxSrc = new LdapContextSource();
ctxSrc.setUrl("ldap://127.0.0.1:389/");
ctxSrc.setBase("dc=test,dc=com");
ctxSrc.setUserDn("admin");
ctxSrc.setPassword("password");
ctxSrc.afterPropertiesSet();
LdapTemplate lt = new LdapTemplate(ctxSrc);
return lt;
}
private LdapTemplate ldapTemplate = ldapTemplate();
public List<User> getAllUsers() {
LdapQuery query= query().base("").where("objectclass").is("user");
return ldapTemplate.search(query, new UserAttributesMapper());
}
Run Code Online (Sandbox Code Playgroud)
这是错误:
10:07:09.406 [main] DEBUG o.s.l.c.s.AbstractContextSource - AuthenticationSource not set - using default implementation
10:07:09.413 [main] DEBUG o.s.l.c.s.AbstractContextSource - Not using LDAP pooling
10:07:09.416 [main] DEBUG o.s.l.c.s.AbstractContextSource - Trying provider Urls: ldap://127.0.0.1:389/dc=test,dc=com
10:07:09.548 [main] DEBUG o.s.l.c.s.AbstractContextSource - Got Ldap context on …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用spring ldap 1.3.1.RELEASE连接到Windows Server 2008上的ldap 活动目录 ,并且 ldap 配置如下:
- spring ldap配置如下:
<bean id="contextSource"
class="org.springframework.ldap.core.support.LdapContextSource">
<property name="url" value="ldap://dc.fabrikam.com" />
<property name="base" value="dc=fabrikam,dc=com" />
<property name="userDn" value="CN=administrator,CN=Users,DC=fabrikam,DC=com" />
<property name="password" value="123456" />
<property name="baseEnvironmentProperties">
<map>
<entry key="java.naming.referral">
<value>follow</value>
</entry>
</map>
</property>
</bean>
<bean id="ldapTemplate" class="org.springframework.ldap.core.LdapTemplate">
<constructor-arg ref="contextSource" />
</bean>
Run Code Online (Sandbox Code Playgroud)
LDAPContactDAO:
@Service
public class LDAPContactDAO implements ContactDAO {
@Autowired
private LdapTemplate ldapTemplate;
public List getAllContactNames() {
return ldapTemplate.search("", "(objectclass=person)", …Run Code Online (Sandbox Code Playgroud)