QuickTip: Audience Targeting and List View Web Parts

Posted: Grant | Comments: 4 | March 11th, 2011
Mar 11

When piecing together a nice little composite application using SharePoint 2010, you will run into circumstances where you will want to hide certain pieces of the UI (Web Parts). As ASP.NET developers we would simply wrap the specified area in a LoginView control and secure it to display for only the appropriate groups. SharePoint Web Parts can do the very same thing through a concept known as audience targeting. We can place a Web Part on a page, and specify that it is only visible to a select set of SharePoint groups or audiences. This works great for a vast majority of the Web Parts in SharePoint, but unfortunately the List View Web Part (one of the more common Web Parts) has a bit of a hitch in its audience targeting giddy-up.

The Scenario

You have created a collection of SharePoint lists and secured them accordingly. You are building the site so that the homepage has a collection of Web Parts that are specific to the job function of the visitor. As such, you are going to use audience targeting on the Web Parts to only show said Web Parts to visitors with the appropriate permissions. The Web Parts on the homepage will be views of the lists contained within the site. 

The Problem

When a user that is restricted from a specific list visits the site; the view of that list displays an access denied message rather than hiding the Web Part from the user. It appears that the security for the list is evaluated prior to the Web Part evaluating the targeted audiences. Since the user does not have access to the list, the access denied message is shown as a result.

The Solution

We can remedy this issue by granting the lowest privilege on the list for the user. As a requirement, the user must not be able to view any list items, so we will give the user the ability to see the list, but not the ability to see any items in the list. This is accomplished by creating a custom permission level that will contain ONLY the Open permission from the Site permissions group. This will allow users possesing this permission to open the list, but will not grant them the permission to open any items in the list. Grant the newly created permission level to the restricted users on the list and the audience targeting on the list views will now function as intended.

4 comments
  1. mohsin says:

    I am facing an issue, i have set target audience in LVWP, it is working fine when I access the web app using machine name i.e, http://servername. But when i access the same web app with same user but with proper portal name “http://portal.abc.com”, tatget audeince feature does not work. When i click modify web-part, i don’t see the target audience option. I have set alternative access mapping for both i.e. machine name and portal name while portal name is default. the user on the web app has only visitor rights but with contribute rights on the list (after breaking inheritance)

    what is tha solution.

    • Grant Harmeyer says:

      I tried reproducing your error and unfortunately I was unable to do so. I have a Web application at http://servername; and an Alternate Access Mapping for the Custom Zone at http://portal.server.local. I am able to access the Audience Targeting settings from the Advanced group of the Web Part settings while logged on to the portal at either zone. However, Audiences are a function of the User Profile service application, so if you do not have a service connection for a UPA on that Web application; you will not be able to specifiy Audience targeting settings.

      Thanks,
      Grant

    • Banjo says:

      Never would have thunk I would find this so inidspenslabe.

Leave a Comment