Announcement Announcement Module
Collapse
No announcement yet.
Context.REFERRAL search problem Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Context.REFERRAL search problem

    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
    Code:
    javax.naming.directory.InitialDirContext.NamingEnumeration<SearchResult>search(String name,String filter, SearchControls cons) throws NamingException { 
    return getURLOrDefaultInitDirCtx(name).search(name, filter, cons); 
    }
    where name="", filter= "(&(objectclass=person)(objectclass=user)(objectcl ass=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:
    Code:
      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.getReferralContext(LdapReferralException.java:147)
    	at com.sun.jndi.ldap.LdapCtx.searchAux(LdapCtx.java:1835)
    	at com.sun.jndi.ldap.LdapCtx.c_search(LdapCtx.java:1746)
    	at com.sun.jndi.toolkit.ctx.ComponentDirContext.p_search(ComponentDirContext.java:383)
    	at com.sun.jndi.toolkit.ctx.PartialCompositeDirContext.search(PartialCompositeDirContext.java:353)
    	at com.sun.jndi.toolkit.ctx.PartialCompositeDirContext.search(PartialCompositeDirContext.java:336)
    	at javax.naming.directory.InitialDirContext.search(InitialDirContext.java:259)
    	at org.springframework.ldap.core.LdapTemplate$4.executeSearch(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.LdapTemplateUserDao.getUser(LdapTemplateUserDao.java)
    applicationContext.xml
    Code:
    	<bean id="contextSource" class="org.springframework.ldap.core.support.LdapContextSource">
    		<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.LdapTemplateUserDao">
    		<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
    Code:
     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
    Last edited by glenn2041; Jun 18th, 2007, 08:38 PM.

  • #2
    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.

    Comment


    • #3
      Solved!

      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

      Comment

      Working...
      X