Home > Sysadmin > LDAP: A quick way to get the number of subentries

LDAP: A quick way to get the number of subentries

I actually manage a LDAP directory with a lot of entries (almost 1,5 millions entries in the same OU). In order to check the replication state, I was looking for a way to count the number of entries in this OU. Thanks to Ludovic Poitou (once again), this information is available via an hidden attribute in the OU.


% ldapsearch -Wxh ldap1 -D "cn=Directory Manager" -b 'ou=people,ou=ssousers,dc=asyd,dc=net' -s base '(objectClass=*)' 'numsubordinates'
[..]
dn: ou=people,ou=ssousers,dc=asyd,dc=net
numsubordinates: 1386931

Depends on the directory server, it’s also possible to get the number of entries for a given backend (the following code was tested for Sun Directory Server 5.2):


% ldapsearch -Wxh ldap1 -D 'cn=Directory Manager' -b 'cn=monitor' -s base '(objectclass=*)' 'backendmonitordn'
[..]
dn: cn=monitor
backendmonitordn: cn=monitor,cn=userRoot,cn=ldbm database,cn=plugins,cn=config
backendmonitordn: cn=monitor,cn=ssoUsers,cn=ldbm database,cn=plugins,cn=config
backendmonitordn: cn=monitor,cn=NetscapeRoot,cn=ldbm database,cn=plugins,cn=config


% ldapsearch -Wxh lynx -D 'cn=Directory Manager' -b 'cn=monitor,cn=ssoUsers,cn=ldbm database,cn=plugins,cn=config' -s base '(objectclass=*)' 'ldapentrycount'
[..]
dn: cn=monitor, cn=ssoUsers, cn=ldbm database, cn=plugins, cn=config
ldapentrycount: 1408974

Categories: Sysadmin Tags:
  1. July 20th, 2009 at 10:32 | #1

    Ludovic write a post with more details. Thanks again!

  1. No trackbacks yet.