tags:

views:

447

answers:

2

I am using an LdapContext in java to query an LDAP server (I think the server is Sun server version 5.2). I use the LdapContext.search(String name, String filter, SearchControls cons) method for the regular querys, but I don't know how to run a query equivalent to sql's "select count(*)". Any idea? Performance is important so I don't want to just run a regular query and count the results.

A: 

Have you tried the Context.list(String name) method? I don't know about the performance and you can't apply filters.

kgiannakakis
+1  A: 

I do not believe there is an equivalent to the "select count(*)" function in SQL.

I think you will have to retrieve the results of your query into some data structure, and count the number of nodes in there.

To my knowledge there is nothing in the LDAP command set that allows this, therefore if you happened to find such a feature in an LDAP server you would have to test to see if it worked anywhere else, if you cared about cross server compatibility.

geoffc