I am trying to force the 'Use Unique Permissions' when a subsite is created.

My preferred approach is to force the radio button on the sbnewweb.aspx page, or to hide that question altogether and set the unique in the feature receiver.

Can I manipulate the sbnewweb.aspx page contents?


You have two supported options:

  1. Add JavaScript through UserCustomAction, which check if it's the sbnewweb.aspx page and if to sets the radio button and hides the section
  2. Add css (through AlternateCssUrl) to the site which hides #ctl00_PlaceHolderMain_idPermSection and have an event receiver to break inheritance (and set AlternateCssUrl)

Finally if you don't care about support (and can do it on all servers) then you could modify "C:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\TEMPLATE\LAYOUTS\newsbweb.aspx", but this isn't supported and might get overriden by service pack.

If you're going with option 1 the following PowerShell can implement that:

$gc = Start-SPAssignment
$site = $gc | Get-SPSite http://sp2013-sp
$script = $site.UserCustomActions.Add()
$script.Name = 'DefaultUniquePerm'
$script.ScriptBlock='var element = document.getElementById("ctl00_PlaceHolderMain_idPermSection_ctl01_RadCreateUniqueSubweb");if(element){element.checked=true;};element = document.getElementById("ctl00_PlaceHolderMain_idPermSection");if(element){element.style.display="none";};'
Stop-SPAssignment $gc
| improve this answer | |
  • Option 1 sounds like the way I want to go, but I am not sure where to do it. I want to intercept the 'New Site' click on the "site Contents' page so I can change the radio buttons status and visibility before the user sees the sbnewsite page. – Tom Hill Jul 16 '16 at 19:18
  • See edited answer – Per Jakobsen Jul 16 '16 at 19:54

If you create a subsite with a PowerShell script, you can easily break the permission inheritance:

$Web = Get-SPWeb "http://web.whatever.com"

It's really that simple!

You would still need to script the SharePoint groups that are included in the site, but the above code breaks the inheritance.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.