22 filters admins reach for, ready to copy: what each one lists, the catch to know, and the AD Reports report that lists the same objects. Then the syntax — operators, the three matching-rule OIDs, escaping.
22 filters in 4 groups
What you type stays in your browser: nothing is sent anywhere.
Users14 filters
Each filter for user accounts starts with the same pair of conditions; the first one says why.
All user accounts
Every user account in the part of the directory you search.
(&(objectCategory=person)(objectClass=user))
Why both:(objectClass=user) alone also matches computer accounts, because the computer class is a subclass of user, and (objectCategory=person) alone also matches contacts.
In AD Reports, the report that lists the same objects: All Users Report.
Enabled user accounts
User accounts without ACCOUNTDISABLE (2) in userAccountControl.
Microsoft: lockoutTime is reset only by a successful logon, so an account whose lockout duration has passed is still listed; add the lockout duration to lockoutTime and compare with the current time to know. The LOCKOUT bit of userAccountControl does not help: since Windows Server 2003 that state is computed, not stored.
In AD Reports, Locked User Accounts lists only the accounts that are locked out.
Microsoft: pwdLastSet 0 means the user must set a new password at the next logon only when userAccountControl lacks DONT_EXPIRE_PASSWORD (65536), hence the second condition.
Both values mean never (Microsoft): a new account gets 9223372036854775807, and one whose expiry date is removed gets 0. The timestamp converter reads either.
(attribute=*) matches every object that has a value in the attribute; objectCategory=person keeps computer accounts out of the list.
In AD Reports, the report that lists the same objects: Users with SPNs.
adminCount = 1
User accounts that are, or once were, in a protected group such as Domain Admins: the system marked them and replaced their permissions with those of AdminSDHolder.
Removing an account from the group does not reset adminCount (Microsoft), so the list includes former administrators; group membership, not adminCount, decides who is protected now.
lastLogonTimestamp runs 9 to 14 days behind with default settings, so choose well over 14 days; accounts that never logged on have no value, hence (!(lastLogonTimestamp=*)). For an exact date, make the value with the timestamp converter.
In AD Reports, the report that lists the same objects: Inactive Users for XX Days; on the Logon Timestamp page.
Created on or after a date
User accounts whose whenCreated is on or after midnight UTC of the day you pick.
Rule 1.2.840.113556.1.4.1941 follows the chain of memberships to the end. Not listed: accounts whose primary group this is (by default, Domain Users), because the group’s member attribute, which the rule follows, does not hold them (Microsoft). The other way round, (member:1.2.840.113556.1.4.1941:=<user DN>) lists every group a user is in. Special characters in the name are escaped for you.
In AD Reports, Everyone in… lists the same members, and also the accounts whose primary group it is.
Groups with no members
Groups with nothing in their member attribute.
(&(objectCategory=group)(!(member=*)))
A group can look empty here and still be the primary group of many accounts, as Domain Users is by default: primary group membership is not kept in member (Microsoft). Check before deleting.
Microsoft’s own example. The value must be decimal: 0x80000000 is 2147483648. Add a scope to narrow it — 2 global, 4 domain local, 8 universal — so 2147483650 lists global security groups and 2147483656 universal ones.
Computer accounts whose operatingSystem begins with the name you enter.
(&(objectCategory=computer)(operatingSystem=Windows Server 2016*))
operatingSystem holds the edition too — Microsoft’s example is Windows Vista Enterprise — so the * at the end matches every edition. Special characters you type are escaped.
In AD Reports, the OS Computer Reports list each Windows version, for example Windows Server 2016.
Domain controllers
Writable domain controllers (SERVER_TRUST_ACCOUNT, 8192) and read-only ones (PARTIAL_SECRETS_ACCOUNT, 67108864).
Microsoft gives a read-only domain controller’s computer object PARTIAL_SECRETS_ACCOUNT and WORKSTATION_TRUST_ACCOUNT, not SERVER_TRUST_ACCOUNT, so 8192 alone finds only the writable ones.
Enabled accounts trusted for delegation to any service (TRUSTED_FOR_DELEGATION, 524288), without the writable domain controllers, which carry the flag by default.
Microsoft’s default for a domain controller is 532480: SERVER_TRUST_ACCOUNT plus TRUSTED_FOR_DELEGATION. A service running as one of the accounts listed can impersonate any client that uses it. No class in the filter: users and computers both.
Presence and wildcards.(attribute=*) matches objects that have the attribute and (!(attribute=*)) those without it; a * inside a value matches any characters, as in (cn=*smith*).
No > or <. The grammar has only >= and <=; for the opposite of one, put ! in front.
Matching rules
Written attribute:OID:=value, with no spaces, and the value as a decimal number — never hexadecimal, and never a constant name such as ADS_GROUP_TYPE_SECURITY_ENABLED.
Microsoft notes that IN_CHAIN searches over a subtree can be processor-intensive where links fan out widely, such as listing every group a user is in.
Escaping special characters
These characters cannot appear as themselves in a value: write each as a backslash and its two hexadecimal digits.
Character
Write
Required by
*
\2a
RFC 4515 and Microsoft
(
\28
RFC 4515 and Microsoft
)
\29
RFC 4515 and Microsoft
\
\5c
RFC 4515 and Microsoft
NUL
\00
RFC 4515 and Microsoft
/
\2f
Microsoft’s ADSI page; harmless elsewhere, since any byte may be written this way
Binary values are written byte by byte the same way: the four bytes 0x00000004 are \00\00\00\04.
Distinguished names.CN=Smith\, John (IT),OU=Staff,DC=example,DC=com goes into a filter as CN=Smith\5c, John \28IT\29,OU=Staff,DC=example,DC=com: its backslash and parentheses are escaped, the rest stays.
Escape a value
Escaped, for the filter
—
What you type stays in your browser: nothing is sent anywhere.