- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-07-2020 10:35 PM
Hi All,
We have starting search directory OU=Users,OU=CompanyA,DC=abc,DC=com, DC=au
We have sub OU called contractors (OU=Contractors) so in AD, it will be OU=Contractors,OU=Users,OU=CompanyA,DC=abc,DC=com, DC=au
How do I exclude OU=Contractors?
I have LDAP OU Definition
Query field = sAMAccountName
Filter = (&(objectClass=person)(sn=*)(!(objectClass=computer)) (!(userAccountControl:1.2.840.113556.1.4.803:=2)))
I've tried to add (!(OU=Contractors)), but this doesn't seem to exclude when I browse or do test load.
Modified filter = (&(objectClass=person)(sn=*)(!(objectClass=computer)) (!(OU=Contractors)) (!(userAccountControl:1.2.840.113556.1.4.803:=2)))
Thank you in advanced for your assistance.
Solved! Go to Solution.
- Labels:
-
MID Server
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-15-2021 10:18 PM
ServiceNow said this is not possible to filter by OU after the searchbase is defined.
If want to be excluded under the searchbase, requires an exclusion using Attributes.
For example:
If you would like to exclude employeeType=Contractor, then use the following filter.
(&(objectClass=person)(sn=*)(!(objectClass=computer)) (!(employeeType=Contractor))(!(userAccountControl:1.2.840.113556.1.4.803:=2)))
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-07-2020 10:47 PM
Hi,
Your exclusion looks fine
(&(objectClass=person)(sn=*)(!(objectClass=computer)) (!(OU=Contractors)) (!(userAccountControl:1.2.840.113556.1.4.803:=2)))
Try to load the data actually and not to check with Browse. Possibly the Browse link doesn't respect the filter
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-07-2020 11:29 PM
Hi Ankur, that doesn't work either. I will submit Hi ticket. Thanks for confirming 🙂

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-07-2020 11:06 PM
Hi,
Normally we use OU filter in lower case. Can you try your as below:
(&(objectClass=person)(sn=*)(!(objectClass=computer)) (!(ou=Contractors)) (!(userAccountControl:1.2.840.113556.1.4.803:=2)))
Also make sure the value Contractor is in correct case.
Thank you,
Palani
Palani
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-07-2020 11:29 PM
Hi Palani, I've tried that few hours ago, unfortunately, it doesn't work either. I will submit Hi ticket. Thanks for confirming.