Good Day,

I'm sitting with the following issue. I'm creating a site collection programmatically... all was working fine on my dev server, until I deployed to test server. When I run the code on the test server the code fails with an unauthorized(Access Denied) exception. After some investigation it turned out that the app pool account for the SharePoint Site did not have sufficient permissions on the contentDB to create site collections. One solution I found was to make the SharePoint site web application pool account the same as central admin. Lo and behold, this resolved my problem. The site collection was being created. BUT, because this is a major security risk (having the same accounts for both web apps) I started looking for another solution. So I found this post: http://blogs.msdn.com/b/yardman/archive/2011/08/22/configuring-sharepoint-2010-self-service-site-creation.aspx

This is to enable self service site creation on the web application for a specific user I.E the SharePoint site app pool account. Note, at this stage I reverted the app pool account to original account so the accounts are now different again.

I followed the steps in the blog by disabling "use self service" for all users and creating permission policy. Setting the permissions for the user policy, adding a user to the security and setting the permissions to use the new Permission policy. So theoretically this should work for the app pool account.

I'm running my code with elevated privileges. Note this is after I enabled self service site creation. Code below

using (SPSite newSpCollection = rootSite.SelfServiceCreateSite("sites/" +  SiteUrl, SiteName, SiteDescription,1033,"COMMUNITY#0",userLoginName,userName,userEmail,null, null, null)){ //do stuff here}
  • Did you add app pool account to the user policy? Also, can you show the full code using RunWithElevatedPreviliges – Nadeem Yousuf Jan 30 '15 at 4:56
  • Hi Nadeem, I did add the app pool account to the user policy but it didn't work.I ended up using secure store and then impersonating the Central Admin app pool account. All is well now. thanks for your response. Question, would it not have something to do with the fact that the app pool account is seen in the SharePoint site as "System Account" and not as the actual app pool account name eg. "svc_spdev"? I would like to know because when I create a site collection in the UI it works, but not via code. – user18075 Feb 2 '15 at 12:06

Your Answer

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

Browse other questions tagged or ask your own question.