Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I am trying to create a site collection in ItemUpdated according to my Event Handler.

SPSecurity.RunWithElevatedPrivileges (
    delegate () {
        using (SPSite oSPSite = new SPSite (sUrlRootSite))
        {
            SPWebApplication oSPWebApplication = oSPSite.WebApplication;
            SPSiteCollection oSPSiteCollection = oSPWebApplication.Sites;

            if (oSPWebApplication.Sites [sUrlRelative] == null)
            {
                oSPSiteCollection.Add(sUrlSite, sSiteName, String.Empty, 1036, sSiteTemplate, sAdminColl, string.Empty, string.Empty);
                oSPWebApplication.Update ();
            }
        }
    });

I am denied access on the oSPSiteCollection.Add(...) function. According to my research, the error comes from my account pool that does not have the rights to write to the web application. Indeed, when I run my application pool account to the farm, I no longer have the problem. Yet it seems to me that it is not recommended that the application pools run the farm account.

I tried to do:

  • an impersonation with SystemAccount => same error

  • throw my creation with timerjob => access denied when the update of my job

How do I resolve this?

share|improve this question
    
This forum is for questions in English, please rewrite the question. –  Robert Lindgren Aug 13 '13 at 17:06
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.