SharePoint 2010 SPPersistedObject Access Denied

27. June 2011

During site collection creation using SharePoint object model API, I faced a very strange error which was related to access denied exception. Although code was running under SPSecurity.RunWithElevatedPrivileges but still it kept throwing access denied errors.

Thanks to Paul, I finally got the clue that this a cool new *bug* in SharePoint 2010 which is not allowing farm admin account to create site collection.

Fix:

Simply run this powershell command to disable Microsoft.SharePoint.Administration.SPWebService.ContentService.RemoteAdministratorAccessDenied property in Microsoft.SharePoint.dll and re-run your code after IISRESET

 

function Set-RemoteAdministratorAccessDenied-False()
{
# load sharepoint api libs
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint") > $null
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Administration") > $null
  # get content web service
$contentService = [Microsoft.SharePoint.Administration.SPWebService]::ContentService
  # turn off remote administration security
$contentService.RemoteAdministratorAccessDenied = $false
  # update the web service
$contentService.Update()
  
}
Set-RemoteAdministratorAccessDenied-False

 

I hope this helps to prevent headache Smile

Happy SharePointing!

SharePoint

Add comment

  Country flag

biuquote
  • Comment
  • Preview
Loading