1
votes

I am developing a sharepoint 2010 visual webpart that will show some sort of ajax content.

I have a property on the webpart for the refresh rate, but I want this property to be set only by an Administrator (or any specific group).

What is the best way to achieve this?

Thank you.

2
Are you asking about making one specific property on the web part configurable only by an Admin? Or would it be acceptable that the entire web part is non-editable/configurable by non-Admins?CBono
Maybe you should just take away the right to customize the web part properties?Vladi Gubler
@CBono well both solutions are ok with me0xFF

2 Answers

3
votes

In our organization, everyone by default is granted "Read" permission to our SharePoint sites through an "All Employees" Active Directory group. This allows users to browse the pages, but not edit them; and if you can't edit a page, you can't edit any web parts on the page.

Those who should have elevated privileges are added to other AD groups (you could use SharePoint groups too), and those groups are granted appropriate permissions.

2
votes

You could create a custom Toolpart. Take a look at this example for a tutorial on how to create one.

Overall, your general steps will be:

  1. Create your custom Toolpart class inheriting from Microsoft.SharePoint.WebPartPages.ToolPart
  2. In your custom Toolpart, override CreateChildControls, write the code to display your textbox as long as the current user has permission (based on whatever rules you choose, ex: SharePoint group).
  3. In your webpart, override GetToolParts and add your custom ToolPart so that it shows up in the right hand side