I am very new to working Active directory. After spending some time on web i was able to get code for getting users from active directory using DirectorySearcher class. However i am facing hard time in getting a list of all supported clauses and keywords
of search.
Kindly share links / list of keywords and clauses. Below are some i found;
&(objectClass=user)
(objectCategory=person)
(manager=...)
(!msExchResourceMetaData=ResourceType:Room)
(!userAccountControl:1.2.840.113556.1.4.803:=2))
Also i tried creating a org chart using Visio and then with DirectorySearcher code. The visio files excludes virtual accounts such as
feedback@abc,.com, meeting rooms, etc. but my Directory searcher code get them as wel .
Kindly help.
Member
2 Points
58 Posts
DirectorySearcher - Clauses and keywords for search
Aug 14, 2016 11:59 AM|shoab shah|LINK
Hi All,
I am very new to working Active directory. After spending some time on web i was able to get code for getting users from active directory using DirectorySearcher class. However i am facing hard time in getting a list of all supported clauses and keywords of search.
The only link i was able to get is https://msdn.microsoft.com/en-us/library/aa746475(v=vs.85).aspx. But got only few keywords.
Kindly share links / list of keywords and clauses. Below are some i found;
Also i tried creating a org chart using Visio and then with DirectorySearcher code. The visio files excludes virtual accounts such as feedback@abc,.com, meeting rooms, etc. but my Directory searcher code get them as wel
.
Kindly help.
All-Star
17652 Points
3510 Posts
Re: DirectorySearcher - Clauses and keywords for search
Aug 15, 2016 12:34 PM|Chris Zhao|LINK
Hi Shoab,
Examples
The following table shows many example LDAP filters that can be useful when you query Active Directory:
(cn=Joe*))
(Note 2)
"Test" or "Admin"
(|(cn=Test*)(cn=Admin*)))
(givenName=*)(sn=*))
manager
(directReports=*)(!(manager=*)))
(|(proxyAddresses=*:jsmith@company.com)
(mail=jsmith@company.com)))
(Notes 3, 19)
with "x", "y", or "z"
with "a" or any number or symbol except "$"
(Note 4)
(userAccountControl:1.2.840.113556.1.4.803:=65536))
(userAccountControl:1.2.840.113556.1.4.803:=2))
(!(userAccountControl:1.2.840.113556.1.4.803:=2)))
(Note 4)
(userAccountControl:1.2.840.113556.1.4.803:=32))
preauthentication" enabled
(userAccountControl:1.2.840.113556.1.4.803:=4194304))
(Note 5)
(|(accountExpires=0)
(accountExpires=9223372036854775807)))
(accountExpires>=1)
(accountExpires<=9223372036854775806))
(unconstrained delegation)
for delegation
(!(groupType:1.2.840.113556.1.4.803:=2147483648)))
(Notes 17, 19)
tab of ADUC
(Note 6)
(msNPAllowDialin=TRUE))
NPS Network Policy" on "Dial-in" tab of ADUC
(!(msNPAllowDialin=*)))
(whenCreated>=20110301000000.0Z))
at next logon
(pwdLastSet=0))
April 15, 2011 (CST) (Note 7)
(pwdLastSet>=129473172000000000))
other than "Domain Users"
(!(primaryGroupID=513)))
"Domain Computers"
(primaryGroupID=515))
"90395F191AB51B4A9E9686C66CB18D11"
(Note 8)
\86\C6\6C\B1\8D\11)
"90395F191AB51B4A"
(Note 8)
-152049171-839522115-1111" (Note 9)
-839522115-1111)
0006BD662041316100943170A3257040000"
(Note 9)
\00\00\00\6B\D6\62\04\13\16\10\09\43\17\0A\32
\57\04\00\00)
Domain Controllers (Note 4)
(!(userAccountControl:1.2.840.113556.1.4.803:=8192)))
(userAccountControl:1.2.840.113556.1.4.803:=8192))
(operatingSystem=*server*))
(operatingSystem=*server*)
(!(userAccountControl:1.2.840.113556.1.4.803:=8192)))
a specified group
(!(memberOf=cn=Test,ou=East,dc=Domain,dc=com)))
(Note 19)
dc=Domain,dc=com)
due to group nesting (Note 10)
cn=Test,ou=East,dc=Domain,dc=com)
including due to group nesting (Notes 10, 19)
cn=Jim Smith,ou=West,dc=Domain,dc=com)
"Smith*", or with cn "Jim Smith*" (Note 11)
replicated to the GC (Notes 6, 12)
(isMemberOfPartialAttributeSet=TRUE))
the Schema container (Notes 4, 12)
(systemFlags:1.2.840.113556.1.4.803:=4))
replicated to other Domain Controllers
(Notes 4, 12)
(systemFlags:1.2.840.113556.1.4.803:=1))
(Notes 4)
the object is copied (Notes 4, 12)
when object deleted (Notes 4, 12)
Resolution (ANR) set (Notes 4, 12)
indexed (Notes 4, 12)
the schema (Notes 4, 12)
set, or FAS (Notes 4, 12)
container (Note 13)
all Global Catalogs. This will identify all DC's
that are GC's. (Note 4)
(options:1.2.840.113556.1.4.803:=1))
PDC Emulator. This will identify the DC
with the PDC Emulator FSMO role (Note 18).
RID Master. This will identify the DC
with the RID Master FSMO role (Note 18).
Infrastructure Master. This will identify the DC
with this FSMO role (Note 18).
(fSMORoleOwner=*))
Schema Master. This will identify the DC with
the Schema Master FSMO role (Note 18).
Domain Naming Master. This will identify the
DC with this FSMO role (Note 18).
(fSMORoleOwner=*))
container (Note 13)
(Notes 4, 19)
reference: http://social.technet.microsoft.com/wiki/contents/articles/5392.active-directory-ldap-syntax-filters.aspx
Best Regards,
Chris
Member
2 Points
58 Posts
Re: DirectorySearcher - Clauses and keywords for search
Aug 16, 2016 06:41 AM|shoab shah|LINK
Thank you Chris!