When you’re developing your custom SharePoint site that is going to be deployed as a solution – the last thing you want is your users accessing the site with SharePoint designer and changing the branding you spent last 2 weeks refining. You probably want to be able to lock down access to edit your site with sharepoint designer.
SharePoint 2010 provides great options through user interface on how to do it : http://[serverurl]/_layouts/SharePointDesignerSettings.aspx
If you deploy your site using a solution deployment you probably want to automate this task through a feature receiver and disable users access automatically.
Here is how something like this would be done through a feature receiver of a site collection (unfortunately you can’t apply this setting on each web):
// Specify whether to allow Site Owners and Designers to edit the sites in this Site Collection using SharePoint Designer.
// Site Collection Administrators will always be able to edit sites.
site.AllowDesigner = true;// True if Specify whether to allow Site Owners and Designers to detach pages from the original Site Definition using SharePoint Designer
site.AllowRevertFromTemplate = true;// True if you want to allow Site Owners and Designers to Customize Master Pages and Page Layouts
site.AllowMasterPageEditing = true;// True if you ok to allow Site Owners and Designers to See the Hidden URL structure of their Web Site
site.ShowURLStructure = true;
Good Luck!
