How to Filter LDAP Users by Creation Date in Active Directory
Question details
The user needs to filter user objects in Active Directory based on their creation date using an LDAP query.

- Product
- Active Directory (LDAP)
- Device & OS
- not provided
- Scenario
- Querying Active Directory to find users created on or after a specific date.
- Observed behavior
- LDAP queries can filter using the whenCreated attribute, but results are not automatically sorted by date and require client-side sorting.
Ensure you have the necessary administrative privileges to run LDAP queries against your Active Directory domain controller and an appropriate client or script editor ready.
Filter Users Using the whenCreated Attribute
Use a specific LDAP syntax filter targeting the whenCreated attribute to find user objects created on or after a given date.
Active Directory stores the creation date of objects in the 'whenCreated' attribute using the Generalized Time format (YYYYMMDDHHMMSS.0Z).
Since LDAP protocols do not natively support server-side sorting of results based on attributes, you will need to apply a sorting function on the client side after retrieving the data.
Format your query using the LDAP syntax. For example, to find users created on or after February 23, 2022, use: (&(objectClass=person)(whenCreated>=20220223000000.0Z)).
Run the constructed query in your preferred LDAP client, Active Directory Users and Computers (ADUC) custom search, or using PowerShell.
Export the returned objects or use your scripting language's native sorting commands, such as Sort-Object in PowerShell, to order the results by the whenCreated attribute.

Manage Your Exported Active Directory Reports with WPS Office
After querying your LDAP directories, export the results to a CSV file and seamlessly analyze them using WPS Office. It provides a lightweight, highly compatible suite to view, sort, and manage your IT reports without the heavy cost.
- 1. Export LDAP Data: Save your LDAP query results as a CSV file from your management console or PowerShell script.
- 2. Open with WPS Spreadsheet: Launch WPS Office and open your exported CSV file.
- 3. Sort and Filter Data: Navigate to the Data tab in WPS Spreadsheet and click Sort to easily organize the users by their creation dates.

Frequently Asked Questions
Can Active Directory LDAP natively sort query results by date?
No, standard LDAP queries do not natively support server-side sorting of results based on an attribute. You must sort the returned objects on the client side, such as through a PowerShell script or a spreadsheet software.
What format does the whenCreated attribute use in LDAP queries?
The whenCreated attribute uses the Generalized Time format, typically written as YYYYMMDDHHMMSS.0Z, where 'Z' stands for UTC (Coordinated Universal Time).
How do I filter LDAP users by a specific date range?
You can combine both greater-than-or-equal-to (>=) and less-than-or-equal-to (<=) operators in your LDAP filter. For example: (&(objectClass=person)(whenCreated>=20220101000000.0Z)(whenCreated<=20221231235959.0Z)).




