More LDAP Query Examples and more AD Specific LDAP Query Examples
(&(objectCategory=person)(objectClass=user)) or (sAMAccountType=805306368)
(objectClass=contact)
(objectClass=user)
(&(&(objectCategory=person)(objectClass=user))(lastLogonTimestamp<=128752108510000000))
(&(objectCategory=person)(objectClass=user)(userAccountControl:1.2.840.113556.1.4.803:=65536))For information on why this works see how to use Filtering for Bit Fields and the Extensible Match Rule 1.2.840.113556.1.4.803.
(&(objectCategory=person)(objectClass=user)(userAccountControl:1.2.840.113556.1.4.803:=2))For information on why this works see how to use Filtering for Bit Fields and the Extensible Match Rule 1.2.840.113556.1.4.803.
(&(objectCategory=Person)(objectClass=User)(!accountExpires=0)(!accountExpires=9223372036854775807))
(&(objectCategory=Person)(objectClass=User)(userAccountControl:1.2.840.113556.1.4.803:=32))
As an example, to find all the groups that "CN=UserName,CN=Users,DC=YOURDOMAIN,DC=NET" is a member of, set the base to the groups container DN; for example (OU=groupsOU,DC=MyDomain,DC=NET) and the scope to subtree, and use the following filter.
(member:1.2.840.113556.1.4.1941:=(CN=UserName,CN=Users,DC=YOURDOMAIN,DC=NET))Where CN=UserName,CN=Users,DC=YOURDOMAIN,DC=NET is the user's FDN and the Extensible Match Rule 1.2.840.113556.1.4.1941.
ldapsearch -H ldaps://serverdc.example.com:636 -x -D "adminguy@example.com" -W -b "DC=example,DC=com" -s sub -a always -z 1000 "(&(objectCategory=person)(objectClass=user)(directReports=*)(!(manager=*)))" "objectClass"
(msExchHideFromAddressLists=TRUE)
(&(msExchHideFromAddressLists=TRUE)(!objectClass=publicFolder))
(proxyAddresses=FAX:*)
(msExchangeHomeserverName=/o=MAILOrg/ou=First Administrative Group/cn=Configuration/cn=Servers/cn=KUNGUR)
(manager:1.2.840.113556.1.4.1941:=CN=Jim,OU=Managed,OU=Accounts,DC=willeke,DC=com)Where CN=Jim,OU=Managed,OU=Accounts,DC=willeke,DC=com is the department manager And return the attribute "mail" as an Example, to send them an email.
For information on why this works see how to use Microsoft Active Directory Extensible Match Rules and the Extensible Match Rule 1.2.840.113556.1.4.1941.