2
votes

I am trying to access User permissions > create subsite enable/disable feature with sharepoint API. How to access User permission for webapplications?

If you go to CA in sharepoint 2010 and click on an web application and then choose User permission in the ribbon it shows you lot of check boxes. Under site permission there is an option for create subsites. This is specifically what I am looking for.

2

2 Answers

1
votes

Based on this ref: Toggle permission in WebApplication.RightsMask)

Powershell:

$webApp = Get-SPWebApplication -Identity http://mywebapp
$allowSubsites = $false


$newPermissions=$null   
if ($allowSubsites){
    $newPermissions=[Microsoft.SharePoint.SPBasePermissions]($webApp.RightsMask -bor [Microsoft.SharePoint.SPBasePermissions]::ManageSubWebs)
}
else
{
    $newPermissions=[Microsoft.SharePoint.SPBasePermissions]($webApp.RightsMask -band [System.Int64](-bnot ([Microsoft.SharePoint.SPBasePermissions]::EmptyMask -bor [Microsoft.SharePoint.SPBasePermissions]::ManageSubWebs)))
}

$webApp.RightsMask = $newPermissions
$webApp.Update()

C#:

   SPWebApplication application = sourceSite.WebApplication;
   application.RightsMask = application.RightsMask | SPBasePermissions.ManageSubwebs;
   application.Update();
0
votes

Web applications (SPWebApplication) themselves have no per-user permissions. The highest level (in terms of the least-granual setting) are site collections (SPSiteCollection).