Workflow Tools Control Yard

Home / Active Directory

LDAP filter builder and explainer

Paste a filter, such as (cn=*bob*) or a long one from a script, to read it in plain words, with Active Directory's bitwise and nested-group rules spelled out. Or build one from the common filters below.

Build a filter

What it findsFilter
User accounts(&(objectCategory=person)(objectClass=user))
Disabled user accounts(&(objectCategory=person)(objectClass=user)(userAccountControl:1.2.840.113556.1.4.803:=2))
Enabled user accounts(&(objectCategory=person)(objectClass=user)(!(userAccountControl:1.2.840.113556.1.4.803:=2)))
Users whose password never expires(&(objectCategory=person)(objectClass=user)(userAccountControl:1.2.840.113556.1.4.803:=65536))
Users who must change their password at next logon(&(objectCategory=person)(objectClass=user)(pwdLastSet=0))
Computer accounts(objectCategory=computer)
Domain controllers(&(objectCategory=computer)(userAccountControl:1.2.840.113556.1.4.803:=8192))
Security groups(&(objectCategory=group)(groupType:1.2.840.113556.1.4.803:=2147483648))
Distribution groups(&(objectCategory=group)(!(groupType:1.2.840.113556.1.4.803:=2147483648)))
Members of a group, nested groups included(memberOf:1.2.840.113556.1.4.1941:={dn})
Direct members of a group(memberOf={dn})
Groups an account is in, nested groups included(&(objectCategory=group)(member:1.2.840.113556.1.4.1941:={dn}))

Escape a value

Escaped:

RFC 4515 writes five characters as a backslash and two hexadecimal digits wherever they are meant as themselves, and any byte may be written that way:

CharacterWritten as
*\2a
(\28
)\29
\\5c
NUL\00
/\2f

Microsoft's list adds the slash, for filters used in an ADsPath.

Operators

OperatorMeaning
=Equals. With a * in the value it is a substring test; attr=* alone means the attribute has a value.
~=Approximately equal, as the server defines it.
>=Greater than or equal to.
<=Less than or equal to.
&And: every filter after it matches.
|Or: at least one filter after it matches.
!Not: the one filter after it does not match.
:rule:=An extensible match with the matching rule named by its OID.

Active Directory matching rules

Active Directory takes these matching rules in an extensible match, attribute:rule:=value. For the two bitwise rules the value must be a decimal number, not a hexadecimal one or a constant name.

OIDNameWhat it doesSince
1.2.840.113556.1.4.803LDAP_MATCHING_RULE_BIT_ANDMatches when every bit of the value is set in the attribute: a bitwise AND.Windows 2000 and later
1.2.840.113556.1.4.804LDAP_MATCHING_RULE_BIT_ORMatches when any bit of the value is set in the attribute: a bitwise OR.Windows 2000 and later
1.2.840.113556.1.4.1941LDAP_MATCHING_RULE_IN_CHAINFor attributes that hold a DN, such as member and memberOf: follows the chain of links, so nested groups count.Windows Server 2008 and later
1.2.840.113556.1.4.2253LDAP_MATCHING_RULE_DN_WITH_DATAMatches values of DN-with-data attributes by their DN part.Windows Server 2012 R2 and later

The flags the explainer names

A bitwise test on userAccountControl or groupType, or a test of sAMAccountType, is read with these names, the same as on the userAccountControl and groupType pages.

BituserAccountControl flagMeaning
1SCRIPTThe logon script runs.
2ACCOUNTDISABLEThe account is disabled: nobody can log on with it.
8HOMEDIR_REQUIREDA home folder is required.
16LOCKOUTThe account is locked out. Windows does not keep this flag up to date in userAccountControl: read msDS-User-Account-Control-Computed or lockoutTime instead.
32PASSWD_NOTREQDNo password is required: the password length policy does not apply, so the password can be empty.
64PASSWD_CANT_CHANGEThe user cannot change the password. Windows does not keep this here: the option is a permission on the account, and setting the bit has no effect.
128ENCRYPTED_TEXT_PWD_ALLOWEDStore password using reversible encryption: the password is kept in a form that can be turned back into clear text.
256TEMP_DUPLICATE_ACCOUNTAn account for a user whose main account is in another domain.
512NORMAL_ACCOUNTA typical user account.
2048INTERDOMAIN_TRUST_ACCOUNTThe account of a trust with another domain.
4096WORKSTATION_TRUST_ACCOUNTThe computer account of a workstation or member server of this domain.
8192SERVER_TRUST_ACCOUNTThe computer account of a domain controller of this domain.
65536DONT_EXPIRE_PASSWORDThe password never expires.
131072MNS_LOGON_ACCOUNTAn MNS logon account.
262144SMARTCARD_REQUIREDThe user must log on with a smart card.
524288TRUSTED_FOR_DELEGATIONTrusted for delegation to any service (unconstrained delegation): its tickets carry the OK as Delegate flag. Normal on domain controllers.
1048576NOT_DELEGATEDAccount is sensitive and cannot be delegated: its tickets are not forwardable, so no service can act as this account.
2097152USE_DES_KEY_ONLYKerberos uses only DES keys for this account.
4194304DONT_REQ_PREAUTHKerberos pre-authentication is not required.
8388608PASSWORD_EXPIREDThe password is older than the maximum password age. Not kept here: Windows shows it in msDS-User-Account-Control-Computed.
16777216TRUSTED_TO_AUTH_FOR_DELEGATIONTrusted to authenticate for delegation: a service running as this account gets forwardable tickets for users who did not log on with Kerberos (protocol transition). Normal on read-only domain controllers.
33554432NO_AUTH_DATA_REQUIREDService tickets for this account carry no PAC, the part that lists the user's groups.
67108864PARTIAL_SECRETS_ACCOUNTThe computer account of a read-only domain controller (RODC). WORKSTATION_TRUST_ACCOUNT is always set with it.
134217728USE_AES_KEYSDefined in lmaccess.h, but Windows clients and servers ignore it.
BitgroupType flagMeaning
1GROUP_TYPE_BUILTIN_LOCAL_GROUPA group the system created in the Builtin container, such as Administrators. Only the system sets this flag.
2GROUP_TYPE_ACCOUNT_GROUPGlobal scope: members come from the group's own domain.
4GROUP_TYPE_RESOURCE_GROUPDomain local scope: members can come from any trusted domain, and the group grants access only in its own domain.
8GROUP_TYPE_UNIVERSAL_GROUPUniversal scope: members can come from any domain in the forest, and the group can grant access anywhere in it.
16GROUP_TYPE_APP_BASIC_GROUPAn application basic group of Authorization Manager. Active Directory itself does not use it.
32GROUP_TYPE_APP_QUERY_GROUPAn application query group of Authorization Manager. Active Directory itself does not use it.
2147483648GROUP_TYPE_SECURITY_ENABLEDA security group: its membership goes into the access token, so it can be given permissions. Without this flag the group is a distribution group.
ValuesAMAccountTypeMeaning
0SAM_DOMAIN_OBJECTThe domain object itself.
268435456SAM_GROUP_OBJECTA global or universal security group.
268435457SAM_NON_SECURITY_GROUP_OBJECTA global or universal distribution group.
536870912SAM_ALIAS_OBJECTAn alias: a domain local security group, the built-in groups included.
536870913SAM_NON_SECURITY_ALIAS_OBJECTA domain local distribution group.
805306368SAM_NORMAL_USER_ACCOUNTA user account. The same value is also named SAM_USER_OBJECT.
805306369SAM_MACHINE_ACCOUNTA computer account.
805306370SAM_TRUST_ACCOUNTThe account of a trust with another domain.
1073741824SAM_APP_BASIC_GROUPAn application basic group of Authorization Manager.
1073741825SAM_APP_QUERY_GROUPAn application query group of Authorization Manager.

Sources

More Active Directory tools