jeudi 29 janvier 2015

Programmatically create site collection self service site creation



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://ift.tt/1BwZMAb


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}







0 commentaires:

Enregistrer un commentaire