0

In my application, I'm getting the list of all sites with this search API call:

/_api/search/query?querytext='contentclass:STS_Site'

However, it does not work for external users, despite having all permissions for certain sites. (It does not work either if external users have access to all sites.) This is the response:

{"error":{"code":"-2147024891, System.UnauthorizedAccessException","message":{"lang":"en-US","value":"Attempted to perform an unauthorized operation."}}

Is there a way to enable searching for external users? (I'd expect the call lists only the sites the user has access to.)

3
  • are you using correct Site URL before _api where external user have permission? Mar 16 at 3:39
  • @KalpeshVaghela no I'm not using sites, it's "global", see my full URL: https://tenant.sharepoint.com/_api/search/query?querytext='contentclass:STS_Site'&selectproperties='Title,Path'
    – privm
    Mar 16 at 14:31
  • In this case all the external user should have atleast read access to tenant.sharepoint.com site otherwise it's not possible. Or another approach could be create one special site collection for external user and provide access to all external user in this site and use this site url in api as base Mar 16 at 18:08

1 Answer 1

1

The default search results page for team sites (osssearchresults.aspx) does not allow external users to see any results, to enable search for external users, we can enable external access to search center and share the search center to external users, then configure team site to use search center instead of default search results page.

The search has security trimming feature which the search results can only be viewed by users who have access to the items. In the content Search web part, the external users can view the results which a user shared the content to external users including other site collections which give access to external users.

Besides, you can add a sourceid of a result source you created to your REST seach api url to let external users to view the results. Reference:

Searching for site content shared with external users

Office 365 SharePoint Search for External Users

Your Answer

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

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