PagedResultsRequestControl and random exceptions
Hi,
I'm looking PagedResultsRequestControl and I'm unsure if it works correctly with LdapTemplate. Here's my bean definition:
<bean id="global.ldapTemplate" class="org.springframework.ldap.core.LdapTemplate" >
<constructor-arg ref="datasource.ldap" />
</bean>
<bean id="datasource.ldap" class="org.springframework.ldap.core.support.LdapC ontextSource">
<property name="url" value="ldap://intranet:389" />
<property name="base" value="xxx" />
<property name="userName" value="xxx" />
<property name="password" value="xxx" />
</bean>
And my code:
List<User> users = new ArrayList<User>();
final int PAGE_SIZE = 100;
PagedResultsRequestControl control = new PagedResultsRequestControl(PAGE_SIZE, null);
do
{
SearchControls searchControls = new SearchControls();
searchControls.setSearchScope(SearchControls.SUBTR EE_SCOPE);
List<User> temp = (List<User>)ldapTemplate.search(baseDn,
memberOf.encode(), searchControls,
new UserAttributesMapper(), control);
users.addAll(temp);
logger.info("blip");
control = new PagedResultsRequestControl(PAGE_SIZE, control.getCookie());
} while (control.getCookie().getCookie() != null);
However when I run the application I keep getting the following exception:
org.springframework.ldap.OperationNotSupportedExce ption: [LDAP: error code 12 -00000057: LdapErr: DSID-0C09068F, comment: Error processing control, data 0, vece...
at org.springframework.ldap.support.LdapUtils.convert LdapException(LdapUtils.java:171)
at org.springframework.ldap.core.LdapTemplate.search( LdapTemplate.java:295)
at org.springframework.ldap.core.LdapTemplate.search( LdapTemplate.java:234)
at org.springframework.ldap.core.LdapTemplate.search( LdapTemplate.java:548)
The problem with this bug is that it's random - you'll note the logger.info("blip") so I can monitor the iterations of the loop. The number of blips output is entirely random! I've read a few posts on this subject and some have suggested connection pooling may be a problem, and hence I'm wondering if LdapTemplate can ever do the job properly given it closes the context after the search has been executed.
Does anyone have a concrete example of this functionality working for thousands of records in the LDAP?
Thanks,
John