I have been looking to wrap security around web parts. I already have security wrapped around documents so only the correct people see the allowed documents. The problem lies when a user does not get to see any documents they have just a header for a web part. Is there any way to hide web parts based on location, security group, or some other form?
6 Answers
Maybe setting Target Audience for web part will help you to solve this issue.
-
1+1 Audience targeting is the out of the box way to solve this. However, if you're using the "free" version of SharePoint then it is not available. sharepoint.microsoft.com/en-us/buy/pages/… Aug 26, 2011 at 14:50
If You are using System.Web.UI.WebControls.WebParts.WebPart class then You can try with setting this.Hidden = true in Your code when You want to hide the whole Web Part under some conditions
You can try webpart audiences, they really annoys me, because hides WP to administrators too, if they are not in audiences groups :o)
http://blog.solanite.com/keith/Lists/Posts/Post.aspx?List=11564265-6153-4557-aee2-72d1f62fa4c1&ID=9
Audiences may not be the answer, as it requires you (in case of SP2010) to have the user profile service running. In addition to that, audiences are showed to people who are in that audience. I guess that it's possible that people do belong to an audience, but don't see any documents. If that's not the case (so people who are in an audience, can see the documents) that will be a solution ;)
One of the difficulties with Audiences is that the content will load for everyone and only show it to people who are in the audience. If you want true security, and you want to use it on a heavily used page, then I would always show the web part and then put some kind of true security check and only provide output when they have access.
I have a couple suggestions.
- If you can set permissions on the list instead of the list items, the list view web part will not show for users that do not have permission to the list. I would suggest this method, becuase item level security is hard to manage and maintain.
- If you must use item level permissions, you can change the header so it doesn't show for everyone. If you need a header for the people who see documents, you can use SharePoint Designer to modify the XSLT of the List View Web part and show your own header.