我試圖訪問用戶權限>使用SharePoint SharePoint創建子網站啓用/禁用功能。如何訪問Web應用程序的用戶權限?以編程方式訪問Sharepoint 2010中Web應用程序的用戶權限
如果您在SharePoint 2010中轉到CA並單擊某個Web應用程序,然後在功能區中選擇用戶權限,則會顯示很多複選框。在網站權限下,可以選擇創建子網站。這是我正在尋找的。
我試圖訪問用戶權限>使用SharePoint SharePoint創建子網站啓用/禁用功能。如何訪問Web應用程序的用戶權限?以編程方式訪問Sharepoint 2010中Web應用程序的用戶權限
如果您在SharePoint 2010中轉到CA並單擊某個Web應用程序,然後在功能區中選擇用戶權限,則會顯示很多複選框。在網站權限下,可以選擇創建子網站。這是我正在尋找的。
Web應用程序(SPWebApplication
)本身沒有每個用戶的權限。最高級別(根據最小粒度設置)是網站集(SPSiteCollection
)。
在此基礎上參照: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();