logo
search
Others

How to Filter LDAP Users by Creation Date in Active Directory

Kushani NimanthikaKushani Nimanthika Oct 10, 2026 868 views

Question details

The user needs to filter user objects in Active Directory based on their creation date using an LDAP query.

How to Filter LDAP Users by Creation Date in Active Directory
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.
Before you start

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.

Solution 1Recommended

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.

1
Construct the LDAP Filter

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)).

2
Execute the Query

Run the constructed query in your preferred LDAP client, Active Directory Users and Computers (ADUC) custom search, or using PowerShell.

3
Sort the Results

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.

Filter Users Using the whenCreated Attribute
Time Zone Formatting: The '0Z' at the end of the timestamp indicates UTC (Coordinated Universal Time). Make sure to convert your target local time to UTC before constructing the query.
Free Microsoft Office alternative

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. 1. Export LDAP Data: Save your LDAP query results as a CSV file from your management console or PowerShell script.
  2. 2. Open with WPS Spreadsheet: Launch WPS Office and open your exported CSV file.
  3. 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.
Fully compatible with Microsoft Excel (.xlsx) and CSV formats.Lightweight and fast, ideal for handling large Active Directory data exports.Familiar user interface for seamless migration from Microsoft Office.Free to use for your daily administrative reporting and data sorting tasks.
QA img-9

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)).