tags:

views:

110

answers:

1

I need to know how many users and groups are in my LDAP directory. The search looks fairly simple:

(| (objectClass=group)(objectClass=user))

The problem is that the API is very limited. I can only get a NamingEnumeration<SearchResult> and it doesn't have a count. I didn't find any functions we can use, like the count in SQL.

Is there any way I can get this count without having to retrieve the full query and count the results with a loop?

A: 

The only way I found to do this was to make a query for an empty attribute array, then loop and increment a counter.

mlaverd