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?
Maybe setting Target Audience for web part will help you to solve this issue.
You can try webpart audiences, they really annoys me, because hides WP to administrators too, if they are not in audiences groups :o)
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.