PDA

View Full Version : Context.REFERRAL search problem



glenn2041
Jun 18th, 2007, 06:08 PM
Hi all,

I was having a problem connecting to the source, but I solved that by adding Context.REFERRAL = 'follow' to the baseEnvironmentProperties.
But now when I do a search, I'm getting a CommunicationException thrown from

javax.naming.directory.InitialDirContext.NamingEnu meration<SearchResult>search(String name,String filter, SearchControls cons) throws NamingException {
return getURLOrDefaultInitDirCtx(name).search(name, filter, cons);
}

where name="", filter= "(&(objectclass=person)(objectclass=user)(objectclass =organizationalPerson)(sAMAccountName=glenn2041))" and defaultSearchControls on subtree scope.



Instead of searching via the url: ldap://wlg-dc1:389 it's trying to search on ldap://nz.co.company:389
Here's the exception:


org.springframework.ldap.CommunicationException: nz.co.company:389; nested exception is javax.naming.CommunicationException: nz.co.company:389 [Root exception is java.net.UnknownHostException: nz.co.company]

Caused by: javax.naming.CommunicationException: nz.co.company:389 [Root exception is java.net.UnknownHostException: nz.co.company]
at com.sun.jndi.ldap.LdapReferralContext.<init>(LdapReferralContext.java:99)
at com.sun.jndi.ldap.LdapReferralException.getReferra lContext(LdapReferralException.java:147)
at com.sun.jndi.ldap.LdapCtx.searchAux(LdapCtx.java:1 835)
at com.sun.jndi.ldap.LdapCtx.c_search(LdapCtx.java:17 46)
at com.sun.jndi.toolkit.ctx.ComponentDirContext.p_sea rch(ComponentDirContext.java:383)
at com.sun.jndi.toolkit.ctx.PartialCompositeDirContex t.search(PartialCompositeDirContext.java:353)
at com.sun.jndi.toolkit.ctx.PartialCompositeDirContex t.search(PartialCompositeDirContext.java:336)
at javax.naming.directory.InitialDirContext.search(In itialDirContext.java:259)
at org.springframework.ldap.core.LdapTemplate$4.execu teSearch(LdapTemplate.java:221)
at org.springframework.ldap.core.LdapTemplate.search( LdapTemplate.java:263)
at org.springframework.ldap.core.LdapTemplate.search( LdapTemplate.java:225)
at org.springframework.ldap.core.LdapTemplate.search( LdapTemplate.java:539)
at org.springframework.ldap.core.LdapTemplate.search( LdapTemplate.java:523)
at org.springframework.ldap.core.LdapTemplate.search( LdapTemplate.java:374)
at org.springframework.ldap.core.LdapTemplate.search( LdapTemplate.java:397)
at org.springframework.ldap.core.LdapTemplate.search( LdapTemplate.java:415)
at nz.co.contactenergy.prepower.dao.security.ldap.Lda pTemplateUserDao.getUser(LdapTemplateUserDao.java)


applicationContext.xml


<bean id="contextSource" class="org.springframework.ldap.core.support.LdapContextS ource">
<property name="url" value="ldap://wlg-dc1:389" />
<property name="base" value="DC=nz,DC=co,DC=company" />
<property name="userName" value="CN=serviceAccountUserName,OU=Service Accounts,OU=Administrators,DC=company,DC=co,DC=nz" />
<property name="password" value="serviceAccountPassword" />
<property name="baseEnvironmentProperties">
<map>
<entry key="java.naming.referral" value="follow" />
</map>
</property>
</bean>
<bean id="ldapTemplate" class="org.springframework.ldap.core.LdapTemplate">
<constructor-arg ref="contextSource" />
</bean>
<bean class="nz.co.company.project.dao.security.ldap.LdapTempla teUserDao">
<property name="ldapTemplate" ref="ldapTemplate" />
</bean>



Update:
I tried setting Context.REFERRAL to ignore. It does get the right host, but now throws a PartialResultException
javax.naming.PartialResultException: [LDAP: error code 10 - 0000202B: RefErr: DSID-031006E0, data 0, 1 access points
ref 1: 'nz.co.company'




BTW: I'm using Websphere 6.1 & Spring LDAP 1.2RC1 & MS Active Directory 2003

Any help would be greatly appreciated.
Cheers

rasky
Jun 19th, 2007, 12:05 AM
I must admit that my knowledge of referrals is rather limited. However, if you really want to ignore referrals you can set the 'ignorePartialResultException' property of LdapTemplate to true.

glenn2041
Jun 24th, 2007, 08:18 PM
Hi all,
I figure out what the problem was:

The contextScope.base was in the incorrect order.
I had set to "DC=nz,DC=co,DC=company" should have been "DC=company,DC=co,DC=nz".

Happy happy happy, joy joy joy!

Cheers