Excluding external users from search results in SharePoint Online

Search in SharePoint Online returns both internal and external users by default. This may  not be desirable. Here’s how to exclude external users from the search results.

External users have account names containing #ext# which makes them easy to filter out. Typically when you search for people you will query against the Local People Results result source. In SharePoint Online we can’t modify this result source like On Premises, but we can clone it and add our own custom filters:

  1. Open SharePoint Admin
  2. Go to search settings and select Manage Result Sources
  3. Copy Local People Results (click the down arrow to find the copy command)
  4. Edit your new result source and find Query Transform
  5. Add  -AccountName:"#ext#"  to the query
  6. Verify that it works using the Query Builder
  7. Save

Remember that you will need to configure search pages and other solutions to use this new result source instead of the default Local People Results!

This entry was posted in Tips and tagged , . Bookmark the permalink.

2 Responses to Excluding external users from search results in SharePoint Online

  1. A Ismaili says:

    Excellent post, I was looking for all kinds of things to exclude, your post helped me that it only requires a dash before the property name!
    Thank you very much! :D

  2. hasan says:

    great help!

Leave a Reply

Your email address will not be published. Required fields are marked *