Created
March 3, 2016 06:01
-
-
Save sksnips/1bb15cc5fb28a0ef076a to your computer and use it in GitHub Desktop.
Code snippet helps to disable the SharePoint Designer Access to the Site Collection
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Author: Shantha Kumar T | |
//Property used: SP.Site.allowDesigner (sp.js) | |
//Supports SharePoint 2010 + and SharePoint Online | |
function disableSiteDesignerAccess() { | |
var clientContext = new SP.ClientContext(); | |
oSite = clientContext.get_site(); | |
//The below line helps to disable the designer access | |
oSite.set_allowDesigner(false); | |
clientContext.load(oSite); | |
clientContext.executeQueryAsync( | |
Function.createDelegate(this, function() { | |
var siteInfo = ''; | |
if (oSite.get_allowDesigner()) | |
siteInfo = 'Designer Access: Allowed'; | |
else | |
siteInfo = 'Designer Access: Not Allowed'; | |
alert(siteInfo.toString()); | |
}), | |
Function.createDelegate(this, function(sender, args) { | |
alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace()); | |
})); | |
} | |
function injectMethod() { | |
disableSiteDesignerAccess(); | |
} | |
ExecuteOrDelayUntilScriptLoaded(injectMethod, "sp.js"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment