PDA

View Full Version : search scope for lookup method



caikn
Aug 4th, 2006, 06:59 AM
Hello,

I am using the ldaptemplate 1.0.2 with Microsoft ActiveDirectory Server.

When I use the lookup method of ldaptemplate, I can't get any results. After using ethereal to analyse the LDAP request, I found out, that the lookup method always use search scope "Base (0x00)".

How can I tell ldaptemplate to use scope "Subtree" during lookup?

Thanks in advance

Kanyin

====LDAP Request when calling lookup method===
Base DN: CN=test,OU=myOrg,DC=myCompany,DC=com
Scope: Base (0X00)
Dereference: Always (0X03)
Size Limit: 0
Time Limit: 0
Attributes Only: False
Filter: (objectClass=*)

=====My context source==================
<beans>
<bean id="contextSource" class="net.sf.ldaptemplate.support.LdapContextSource">
<property name="url" value="ldap://myserver:389" />
<property name="base" value="DC=test,DC=com" />
<property name="userName" value="CN=testUser,CN=Users,DC=test,DC=com" />
<property name="password" value="****" />
<property name="dirObjectFactory" value="net.sf.ldaptemplate.support.DefaultDirObjectFactor y" />
</bean>

<bean id="ldapTemplate" class="net.sf.ldaptemplate.LdapTemplate">
<constructor-arg ref="contextSource" />
</bean>

<bean id="ldapDao" class="com.test.LdapDaoImpl">
<property name="ldapTemplate" ref="ldapTemplate" />
</bean>
</beans>

rasky
Aug 4th, 2006, 07:45 AM
The lookup operation is a direct lookup, not a search, and as such it has no search scope. You supply the distinguished name of the entry you want to look up, relative to the base path you have specified for your ContextSource.

I suspect that your problem is that your server requires an authenticated context for read-only operations. Try setting the authenticatedReadOnly property of your LdapContextSource to 'true' and double check that the distinguished name you are supplying is relative to the specified base context.

caikn
Aug 4th, 2006, 10:02 AM
your are right. after setting the property, the lookup works just fine.

thanks for the fast and helpful answer

Kanyin