Search Result Web Part Conditional Query

Iron Contributor

Hello,

 

I have a search result webpart that presents all the sites that the user has access to. However, if a user has access to just a document library in a site, it's not listed in there. So, I am trying to create a query that will list all the sites that the user has access to along with the document libraries where user doesn't have access to the site.

 

Forexample: If a user has access to sites A, B and C and also have access to a 'Shared Docs' document library in site D. The user doesn't have access to anything but 'Shared Docs' document library in site D.

Using the query, contentclass:STS_Web contentclass:STS_Site will list the sites A,B and C but nothing for site D. I would like to include the link for the 'Shared Docs' document library in the list of sites that are being displayed.

 

I am not sure it's even feasible.

 

Any thoughts?

 

Thank you for the help in advance.

 

 

 

 

 

 

2 Replies

Hi Bhavpreet,

 

I haven't gone ahead and tested this however my initial thinking was items underneath Site D, from your example, would not be displayed as the user doesn't have access to Site D. Therefore, the search query would get to Site D, take note it doesn't have permissions and move on subsequently not displaying items underneath Site D.

 

You could probably hard input the URL but that is a messy solution, when I have the time I may conduct some tests and update my answer.

 

Thanks,

Tom

Hello Tom,

If we go with the usual query to list the sites (contentclass:STS_Web contentclass:STS_Site), then yes it wont list the site as the user doesn't have access to the site.

It might needs to be combined with the query to get the document libraries (contentclass:STS_List OR contentclass:STS_List_DocumentLibrary) but, it will list the document libraries of the sites where user has full access i.e. it will list the document libraries for Site A, B and C as well.

I would like to have a query that will return the list sites that the user have access to and if the user doesn't have access to the full site then will return the part where user has access.

Thank you.