Late last week Brian Caauwe and I spent some time looking into how to lock down SharePoint Designer access. One of the first options that is available is to modify a Site Definition’s ONET.xml file. All of the instructions are available here (thanks to the SharePoint Designer Team!) so I’m not going to walk through each step – the main thing to note is that we’re updating the Project element to include a new attribute, “DisableWebDesignFeatures” which you can see here:
Once the new attribute is in place (and IIS is reset), any attempt to open the site in SharePoint Designer gives you a very friendly error message:
What is great is that if you update the Site Definition and remove the “DisableWebDesignFeatures” attribute (and reset IIS), the site will open in SharePoint Designer just fine. I did not think that was the case so I was pretty interested to see what exactly was going on behind the scenes.
So how does SharePoint Designer know when it is ok to open? To find that answer we can turn to our best friend, Fiddler. By using Fiddler while we attempt to open a site with SharePoint Designer, we can see that a number of RPC calls are made:
The third RPC call (the one to author.dll) is the one we’re most interested in: it calls the Open Service FPRPC method. The response we get is almost 3kb of ALMOST-html garble (thanks again, Vermeer). Hidden in the response is a familiar attribute with a new name – vti_disablewebdesignfeatures2 with a value of wdfopensite:
If we were to remove the attribute from our ONET.xml file and then reset IIS, the attribute also goes away from our Open Service request. Here’s where Brian stepped in with the best idea ever – can we possibly set the same variable in an SPWeb’s PropertyBag? I thought he was crazy but, as is frequently the case when I question Caauwe, I was wrong!
First I opened up PowerShell and looked at the properties stored in an SPWeb’s PropertyBag:
From there I added a new property matching the existing “vti_” pattern, using the property name we found in the Open Service method’s response:
and now, without an IIS reset, I get our friendly error message stating that access via SharePoint Designer has been disabled:
Brian and I used this new found knowledge to create a new release for the NoSPD Codeplex project that wraps this functionality into a feature. Check it out here!