SearchControls setReturningAttributes is limiting number of responses

I'm using LDAP to query an Active Directory in Java 1.5.0_01.

My intent is to pull all members of a group. My problem is that I'm getting the same number of members returned as the size of my attributes array, regardless of the number of members in the group, or the count limit I set on how many results should be returned. The number of members returned and the attributes of those members should have no correlation, but they appear to.

I'm using this array to get the attributes of the group that I'm interested in ...

String[] attributes = new String[] { "distinguishedName", "name", "objectCategory", "member"};

and obviously this command:

srchControls.setReturningAttributes( attributes );

With this array I was only receiving 4 members of my group (there are around a dozen members that should be appearing).

Later I added the description field for this array

String[] attributes = new String[] { "distinguishedName", "name", "objectCategory", "member", "description"};

Then noticed I was receiving 5 members of my group.

That is when I spotted this problem. If I simply don't set the return attributes I get all members back. Unfortunately I get all their data back too, which I would rather avoid for efficiency ... but getting all members is better than getting some back efficiently.

Both before and after I make the srchControls.setReturningAttributes( attributes ) call I tested srchControls.getCountLimit() and got 0 both times. The documentation states "0 indicates that all entries will be returned" so that is expected.

I also tried setting it with srchControls.setCountLimit(1000) after setting the return attributes but still only received a number of members equal to the size of my attributes array.

The only place I use the attributes array is in this call. I never pull the size of it, nor do I even use it in another line of code other than those shown.

Am I missing something? Is this a bug? Has it been fixed in a later version? Any help you could offer would be appriciated. Thanks!

[2110 byte] By [shalera] at [2007-11-26 13:11:42]
# 1

Have a look at both "JNDI, Active Directory, Paging and Range Retrieval" at http://forum.java.sun.com/thread.jspa?threadID=578347&tstart=0 and "JNDI, Active Directory and Group Memberships" at http://forum.java.sun.com/thread.jspa?threadID=581444&tstart=150

While both samples only retrieve the member attribute, you can add other attributes. For example in the range retrieval example you could make the following changes:String returnedAtts[]={"member;Range=" + Range,"objectCategory","distinguishedName"};

searchCtls.setReturningAttributes(returnedAtts);

Just beware that every iteration of the range will also return the objectCategory & distinguishedName values.

If the number of results being returned is dependant on the size of your returnedAttributes array, there has to be a bug in your code.

adler_stevena at 2007-7-7 17:27:39 > top of Java-index,Core,Core APIs...
# 2
Thank you for your answer. I was hoping to get confirmation that the bug is mine and that I'm missing something. Thanks!I'd also like to say thank you to you too adler_steven. I've read a bunch of your stuff on this forum and its great!
shalera at 2007-7-7 17:27:39 > top of Java-index,Core,Core APIs...