directory-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From amit nanda <>
Subject Getting total count of entries in a container
Date Thu, 11 Dec 2014 04:32:45 GMT

I would like to  get the total count of entries under a container.
I application will have around 100000 entries, i can't get a direct way to
to this.

Here is a sample of workaround the code i wrote

Stopwatch timer = Stopwatch.createStarted();

final SearchControls searchControls = new SearchControls();
searchControls.setReturningAttributes(new String[]{"uid"});

int count = 0;
String filter =

count +="ou=services,ou=configuration,ou=system",
searchControls, new AttributesMapper<Object>() {
public Object mapFromAttributes(Attributes attributes) throws
NamingException {
return "";


Logger.getLogger("Ldap-Client").info("Count = : " + count);
Logger.getLogger("Ldap-Client").info("Duration = : " + timer);

I tried this with around 20,000 entries, time taken was around 4 seconds,
which is bit more that my requirement.

I also see that in PagedResultsDirContextProcessor I see that there is a
getResultSize(), which should give us the total count according to the doc,
but this doesn't seems to be working for me.

Is there any way i can get the total count, faster than this.


  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message