Working in SharePoint 2013, I am trying to configure the Search Results query, to exclude all generic accounts (i.e. System accounts, test users, etc.). Our AD has these users segregated into a separate OU, and I think I can use that exclude these users from the results of a People Search. But, I'm having trouble configuring the query in the Search Results web part, to do this.

There is an existing property in the User Profile called Distinguished Name which includes the value OU=Users.Departmental for these generic accounts: OU=Users.Departmental

I have configured a Managed Property called DistinguishedName, that is mapped to this field: Managed Property

When I go to the Search Results web part, I have created a query that uses:

{searchboxquery} -DistinguishedName:Users.Departmental

No matter what I do, I can't seem to get the query to exclude users that have Users.Departmental in their Distinguished Name field value. Any advice or suggestions on how to resolve this would be appreciated.

  • I have the same problem, if you managed to solve this problem, can I ask for a solution. Thanks.
    – Raziel
    Jul 31, 2018 at 8:40
  • This does not really answer the question. If you have a different question, you can ask it by clicking Ask Question. You can also add a bounty to draw more attention to this question once you have enough reputation. - From Review
    – moe
    Jul 31, 2018 at 9:23

2 Answers 2


Even though I'd previously run a Full Crawl, the DistinguishedName value was blank. I decided to execute a Full Crawl again, and lo and behold, the Distinguished Name Managed Property was populated (verified by executing a REST search query). At that point, the original query worked in the Search Results web part.

Here are my notes for implementing this, if anyone else finds this useful:

  1. Mark Distinguished Name Property as Indexed -Central Admin -Manage Service Applications -User Profile service -Manage User Profile Properties -Edit Distinguished Name -Mark it as 'Indexed' = Yes

  2. Map a Managed Property to the Distinguished Name property -Central Admin -Manage Service Applications -Search Service Application -Search Schema -New Managed Property -Property Name: DistinguishedName -Text, Searchable, Queryable, Retrievable, Allow Multiple Values, -Add a mapping to Crawled Property: People:SPS-DistinguishedName, select second option (Include content from first crawled property) -OK

  3. Execute a 'Full Crawl' on the People Search Results Source

  4. Navigate to the People Search Results page. -Edit the page -Edit the Search Results web part -Click Change Query -In the Query Text field, add the following: {searchboxquery} -DistinguishedName:Users.Departmental -Click OK -Click OK or Apply -Save/Publish the page


Rather than doing this from Query alone, have you tried adding this as an exclusion filter in the User Profile Service? This would eliminated the profile and thus remove them from the People Index. (Most of them anyway.)

The other thing that may be happening is the dot (".") in your Users.Departmental may be the issue. Just for testing I would try -DistinguishedName:Departmental just to see if it works. Once you figure out the issue you can alter the query as needed. At that point I would modify the OOB People Result Source so this becomes the Farm standard.

Oh, and when you created the Managed Property did you put it in the PeopleIdx if not your query won't work.

  • Unfortunately, many of these generic accounts are used to login to SharePoint. If I remove them using an exclusion filter on the UPS, users won't be able to login to SharePoint with these accounts, right? I tried using -DistinguishedName:Departmental as you suggested, but it didn't seem to do the trick. Is there a way to enumerate the values that are stored in the Managed Property called DistinguishedName? I'd like to confirm that "Users.Departmental" is actually part of the value that is being stored in that Managed Property.
    – cflbasser
    Apr 1, 2016 at 13:12
  • I used REST to execute a search query, to get the value of the Managed Property called DistinguishedName: https://example.com/search/_api/search/query?querytext='userid'&selectproperties='AccountName,DistinguishedName'&sourceid='B09A7990-05EA-4AF9-81EF-EDFAB16C4E31'. I found that the value is coming back blank: <d:element m:type="SP.KeyValue"> <d:Key>DistinguishedName</d:Key> <d:Value></d:Value> <d:ValueType>Edm.String</d:ValueType> </d:element>
    – cflbasser
    Apr 1, 2016 at 14:19
  • Updated my answer, be sure you created the Managed Property correctly. In this case, with user profiles, it has to be done in Central Admin, not at the site or Site Collection. Apr 2, 2016 at 12:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.