Set SharePoint Designer 2010 Settings Programmatically

Relates to: SharePoint  2010, SharePoint Designer

Once you’ve set the look and feel of a site, chances are you want to prevent users from using SharePoint Designer to change that look and feel. Luckily you can set the SharePoint Designer 2010 settings, either programmatically or through the user interface. In SharePoint 2010, you can access the SharePoint Designer 2010 settings from the user interface  either through the site collection’s settings or the url: http://%5BsiteCollectionUrl%5D/_layouts/SharePointDesignerSettings.aspx:

If you want to set these settings programmatically, you’ll need to create a feature receiver scoped at the site collection that will restrict the site collection’s SharePoint Designer settings when the feature is activated. In the FeatureActivated method, get the site collection and change the settings:

SPSite cSite = properties.Feature.Parent as SPSite;

cSite.AllowDesigner = false; // enable SharePoint Designer

cSite.AllowRevertFromTemplate = false; //detach pages

cSite.AllowMasterPageEditing = false; //customize master pages and page layouts

cSite.ShowURLStructure = false; //see hidden url structure

cSite.RootWeb.Update();

*It’s important to note that the site collection SharePoint Designer settings only apply to the site owners and designers — a site collection administrator would still be able to use SharePoint Designer on the site collection even when all the settings are set to false.

You can go one step further and staple this feature to the specific site templates (ie. Global or STS#1) so that the feature is automatically activated when a site based on that site template is created.

You can also hide the “SharePoint Designer Settings” link in the Site Collection settings to make it less likely for users to stumble upon the option (although users would still be able to access it via the url).

If you want to restrict the SharePoint Designer settings for all the site collections within the web application, its easier to set these SharePoint Designer settings for the web application instead of for each site collection within the web application.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: