Problem while using controls with MS ActiveDirectory
Hi ,
I am facing a strange problem while using controls with Active Directory.
I am using a SearchControl to set the total number of users to be returned matching the filter to 800 , and used the PagedResultControl to set the page size as 400 . Here is the the sample code i used
SearchControls controls = new SearchControls();
int pageSize = 400;
controls.setCountLimit(800);
byte[] cookie = null;
Control[] ctls = new Control[]
{
new PagedResultsControl(pageSize)
};
context.setRequestControls(ctls);
do
{
NamingEnumeration result = context.search("",this.getUserObjectclass(),filter,controls);
while (result != null && result.hasMoreElements())
{
resultEnum.add(result.nextElement());
}
// Got the cookie from response controls
cookie = respcontrolobj.getCookie();
//Sending cookie back to the server
context.setRequestControls(new Control[]
{
new PagedResultsControl(pageSize, cookie, Control.CRITICAL)
});
}
while ((cookie != null) && (cookie.length != 0));
But even after returning 800 users the cookie returned form the server
is not null, hence the while loop runs over and over to return all the users matching the filter , ie more than 800.
Please help me to find out where it could have gone wrong . I am using MS Active Directory 2003

