Friday, January 16, 2015

Display a Security Trimmed Listing of Sites Using SharePoint Search



kudzuDepending on where you live, and how frequently you travel by car, you might have come across vast areas taken over by kudzu.  I’m always amazed at the vast land area kudzu can quickly take over.  I’ll bet if you stared at it for a while, you could actually see it grow.

As SharePoint grows in your organization, so do the number of sites each of your users has access to.  So how do you go about showing a listing of sites the user has access to, especially if their sites are separate site collections or even web applications?

If you don’t provide something for the users, it might be easier for them to find a green crayon in a field of kudzu.  You need something to help users find their sites besides relying on them to have well organized bookmarks. 


If you’re a tried and true SharePoint guru, you are already familiar with the notion that there are countless ways to do most things in SharePoint.  This is no exception to that. 

In this article I’ll show you how to quickly and easily use your existing SharePoint search to display a list of sites a user has access to. 

There’s a few things that make this method a quick and painless option.  The main reasons are that you undoubtedly already have search configured and fine tuned, SharePoint search by default is already security trimmed, and SharePoint ships with search web parts ready for you to add and configure.

For this example, I’ll show a web application, with multiple site collections, setup as extranet sites using our ExCM product.  This would work just the same for your team sites, project sites, or any other type of site in your SharePoint farm.

The first step is to choose the page that will contain the listing.  I’m choosing to use my web application root home page.  For this scenario, a user simply has to remember, or have bookmarked, a single friendly url.  When they navigate to that url, they will have their security trimmed listing of sites presented via SharePoint search. 

Now you need to edit your page, and add the Search Results web part.
image

Next, edit the web part properties.  You are likely familiar with many of the options so go ahead and give it an appropriate title (i.e. My Extranet Sites) and choose other appearance options. 

The real magic happens when you select the “Change Query” button.  In the “Query text” box enter:
contentclass:STS_Site Path:https://yoururl.  For my test it looks like this:
image

This query is telling SharePoint – display only content matching STS_Site (site collections) under the web application https://extranet.local

You’re done now.  A security trimmed listing of site collections your users have access to is ready to be consumed.  There are many more configuration options you can set as well to fine tune this for your specific needs.  One thing I did was changing the result settings to show 25 results, rather than the default of 10. 

I hope this turns you into a hero for giving your users a nice organized view of the sites they have access to and allowing them to delete all those bookmarks and IE desktop shortcuts.  Best of all, this can all be done right away without any custom coding, 3rd party installing, or disruption to your SharePoint farm.

No comments: