Restrict disabled users from showing up in SharePoint Online search results

An interesting ask came up the other day , “Is there a possibility to restrict disabled users from showing up in SharePoint Online search results” Thanks to our friend Sridhar Narra who  shared some great insights to the solution. To achieve these we need to make few changes to On-Premise Active Directory.

1.Set  msExchHideFromAddressLists property of the user that needs to be  hidden from people search or Delve to True or 1.

2.Azure Active Directory Sync should synchronize the changes to Office365 directory services.

3.The change would eventually propagate  all the way up to SharePoint Online (SPO)User Profiles.

4.Once changes are synched to User profiles, incremental crawl should crawl the profiles that were set with SPSHideFromAddressLists property.

5.To verify crawl has updated the index with the above changes, perform the steps below

Browse to search center in SharePoint Online and click on People search vertical. Type below query and you should see the result of the person that you intend to hide, example

To hide profiles with SPSHideFromAddressLists property updated in search index,example


6.Finally following steps allow default people search to exclude all profiles with SPS-HideFromAddressLists set.

  1. Browse to enterprise search people results page example
  2. Edit Search Results page.
  3. Edit People Results Web part.
  4. Change query.
  5. Change Query Text from {searchboxquery} to {searchboxquery} –“SPS-HideFromAddressLists”:1
  6. Apply changes.
  7. Check-in changes and publish the page.

Now disabled users should no longer show up in search results.