Reputation: 1
I'm trying to get the number of elements that match a search query.
The point is, the search will produce SizeLimitExceededException from time to time, and I would like to know exactly how many entries match the query. Therefore, counting the results obtained from the search is not an option.
Any ideas?
Thanks in advance :)
Upvotes: 0
Views: 2108
Reputation: 11132
There is a reason for the size-limit being exceeded, it prevents clients from trawling the directory for object information, counting the number of objects, and so on. Trawling the directory is a) a security risk and b) will have a negative impact on old legacy server software.
There is also a time-limit that constrains the number of seconds a server may spend on a particular search which may come into play.
If all the entries (and no other)s that match your search filter are subordinate to an object, configure the server to support the numSubordinates
attribute. That attribute (if supported) is the number of objects subordinate to the object in which the numSubordinates
attribute appears. This method requires that all and only entries that match your search filter be stored subordinate to an object and that no other objects are subordinate to an object.
A plugin could be written to provide functionality; a plugin often has root DN access to the server database and often is not subject to access controls and as such may be able to count entries.
On recent, professional-quality servers, an DN could be created with the appropriate privileges to count the number of entries. An application could be furnished with this DN and credentials for the purpose of simply counting the entries.
Upvotes: 1