Query Active Directory to find the count of records in a container

Home | Tutorials | Compare

 

This tutorial explains how to query ldap to find the count of records in a container.

The SQLLDAP count syntax is simple and look like this:

SELECT COUNT(*) FROM Container

In this tutorial we will explain how to find the count of all the records in an active directory users container 'CN=Users,DC=ldapsoft,DC=local', count of all the records created in the last 3 months and count of all records created yesterday.

To run the statements, first connect to Active Directory (To create a new connection please see Connecting to Active Directory remotely). After successful connection, select the SQL button from the top menu, this will open the sql tab where you can enter the sql statements.

 

Active Directory count of records

 

To find the count of all records in the container CN=Users,DC=ldapsoft,DC=local enter the following sql statement in the SQL Pane:

SELECT COUNT(*) FROM CN=Users,DC=ldapsoft,DC=local

and also set the max results to '0' (no limit)

 

Count of records from Active Directory

 

Now Click the Run button from the top menu or from right click context menu. After successful run a dialog will open showing a total number of records in the container CN=Users,DC=ldapsoft,DC=local

 

Active Direcotry count of records

 


To find the count of all records created in the last 3 months we enter a statement as:

SELECT COUNT(*) FROM CN=Users,DC=ldapsoft,DC=local WHERE createTimestamp >= CurrentTimestamp -3 months

when you run this statement a dialog will appear showing you a total number of records in container CN=Users,DC=ldapsoft,DC=local created in last 3 months

 

 


To find the count of all records created yesterday, we enter a statement as:

SELECT count(*) from'CN=Users,DC=ldapsoft,DC=local where createTimestamp <= CurrentEndofDay -1 days and createTimestamp >=CurrentStartofDay -1 days

when you run that statement a dialog will appear showing you a total number of records created yesterday in container CN=Users,DC=ldapsoft,DC=local

 

LDAP Count of records created yesterday