Answered by:
Hiding webparts based on Permissions

>
Question
-
Using WSS 3.0 and SPD I was looking to find a way to hide webparts based on the user's permissions group. Is this possible?
If not is there a way of deleting the access error message? If I hide the title/border of the webpart, the user only sees the error message and if I can make this blank it basically allows me to hide the webparts I choose.
thanks.Friday, September 18, 2009 9:44 AM
Answers
-
you can use SPSecurityTrimmedControl the property PermissionsString is associated to role permission, add the roles you nedd.<SharePointWebControls:SPSecurityTrimmedControl ID="AgendaPermission" runat="server" PermissionsString="AddListItems">........Add your webpart</SharePointWebControls:SPSecurityTrimmedControl>On top of you page you need to make reference to SharePointWebControls.<%@ Register TagPrefix="SharePointWebControls" Namespace="Microsoft.SharePoint.WebControls"Assembly="Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>List of permissions
André Lage Microsoft SharePoint and CRM Consultant
Blog:http://aaclage.blogspot.com
Codeplex:http://spupload.codeplex.com/http://simplecamlsearch.codeplex.com/- Proposed as answer by Raghu Vayu Nandana K Friday, September 18, 2009 11:16 AM
- Marked as answer by Lambert Qin [秦磊] Friday, September 25, 2009 7:10 AM
Friday, September 18, 2009 10:04 AM
All replies
-
you can use SPSecurityTrimmedControl the property PermissionsString is associated to role permission, add the roles you nedd.<SharePointWebControls:SPSecurityTrimmedControl ID="AgendaPermission" runat="server" PermissionsString="AddListItems">........Add your webpart</SharePointWebControls:SPSecurityTrimmedControl>On top of you page you need to make reference to SharePointWebControls.<%@ Register TagPrefix="SharePointWebControls" Namespace="Microsoft.SharePoint.WebControls"Assembly="Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>List of permissions
André Lage Microsoft SharePoint and CRM Consultant
Blog:http://aaclage.blogspot.com
Codeplex:http://spupload.codeplex.com/http://simplecamlsearch.codeplex.com/- Proposed as answer by Raghu Vayu Nandana K Friday, September 18, 2009 11:16 AM
- Marked as answer by Lambert Qin [秦磊] Friday, September 25, 2009 7:10 AM
Friday, September 18, 2009 10:04 AM -
I would use audiences, which are set on the webpart by picking a custom audience or security group. Not sure you can wrap a SPSecurityTrimmedControl around a webpart which exists in a zone, you could possible hide the whole zone using the security trimmed control.
My SharePoint Blog - http://www.davehunter.co.uk/blogFriday, September 18, 2009 11:01 AM -
Dave he uses "wss 3.0"
André Lage Microsoft SharePoint and CRM Consultant
Blog:http://aaclage.blogspot.com
Codeplex:http://spupload.codeplex.com/http://simplecamlsearch.codeplex.com/Friday, September 18, 2009 11:06 AM -
Thanks Andre,
Not exactly sure where I am supposed to enter this code or if it already exists there. Do I edit this in the Code tab of SPD? The "hiding the entire zone" that Dave pointed to seems a good option for me, where would I put this and what would the code look like?
Apologies for being a bit bad at code :D
Thanks..Friday, September 18, 2009 12:25 PM -
Open sharepoint Desinger, open your sharepoint site, select the page you want to change or create as aspx page.On Menu "Insert>Sharepoint Controls>Webpart Zone"Here a example:<SharePointWebControls:SPSecurityTrimmedControl ID="AgendaPermission" runat="server" PermissionsString="AddListItems"><WebPartPages:WebPartZone ID="g_E3954880FE1A4F0B9378ADB1DD5A1E4E" runat="server"Title="Zone 1"><ZoneTemplate></ZoneTemplate></WebPartPages:WebPartZone></SharePointWebControls:SPSecurityTrimmedControl>
André Lage Microsoft SharePoint and CRM Consultant
Blog:http://aaclage.blogspot.com
Codeplex:http://spupload.codeplex.com/http://simplecamlsearch.codeplex.com/Friday, September 18, 2009 12:41 PM -
Sorry can you expand on the format of the code. Just wondering what goes in the "AgendaPermission" bit or if that is a standard entry? the webzone I am trying to lock is named "Test".
So far I understand that I am meant to write that code around the WebPartZone that I want to hide.... Is that correct?Friday, September 18, 2009 2:58 PM -
AgendaPermission is only the id of the object, you can change to a diferent name, the essencial is using the property PermissionsString do define the permission you need.dont forget to add the tag on top page<%@ Register TagPrefix="SharePointWebControls" Namespace="Microsoft.SharePoint.WebControls"Assembly="Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>"So far I understand that I am meant to write that code around the WebPartZone that I want to hide.... Is that correct?"yes
André Lage Microsoft SharePoint and CRM Consultant
Blog:http://aaclage.blogspot.com
Codeplex:http://spupload.codeplex.com/http://simplecamlsearch.codeplex.com/Friday, September 18, 2009 3:10 PM -
Thanks again Andre.
1 Last issue.... I have the standard groups set at present, and I understand that the "ManageWeb" PermissionString effectively relates to Admin, however Im not sntirely sure how this section of the code works. Is it possible to put the Permissions Group name in there (i.e. PermissionsString="PermissionGroupName")? Is there a list of these that shows what they link to?Friday, September 18, 2009 3:31 PM -
no, just permission roles, You can give multiple permission by "," (comma), are associated to that group you want to manage.example:
PermissionsString="AddAndCustomizePages, ManageLists"
but you can try this trick.
André Lage Microsoft SharePoint and CRM Consultant
Blog:http://aaclage.blogspot.com
Codeplex:http://spupload.codeplex.com/http://simplecamlsearch.codeplex.com/Friday, September 18, 2009 3:45 PM -
I only seem to have 4 permission roles at present. (Full Control, Design, Contribute, Read Only). However, these don't allow me to do everything I want (i.e. some users will have the same permissions, but only to different webparts). Is it possible to be more specific in terms of how I can deal with these groups? Do I require MOSS to have more permission options?Friday, September 18, 2009 4:24 PM
-
Hi,
No, it is not possible with WSS 3 OOB features.
the SPSecurityTrimmedControl suggested by André could hide web parts based on Permissions, but cannot achieve the same goal for groups.
Audiences targeting suggested by Dave is a good way, but it requires MOSS.
Hope the information can be helpful.
-lambert
Sincerely,Lambert Qin | Microsoft TechNet Managed Forum SupportPosting is provided "AS IS" with no warranties, and confers no rights.- Marked as answer by Lambert Qin [秦磊] Friday, September 25, 2009 7:10 AM
- Unmarked as answer by Sashabaz Wednesday, October 7, 2009 11:24 AM
Tuesday, September 22, 2009 6:08 AM