Sign up ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I am using the SharePoint Object Model to create new sites programmatically (with a custom web part). It works fine but I am wondering if it is possible to grant permission for groups as well?

When I create the site I have set it to not inherit permission:

newWeb = SPContext.GetContext(HttpContext.Current).Web.Webs
    .Add(siteUrl, siteName, siteDescription, (uint)1033, siteTemplate, true, false);

In the GUI I can then go to Site Actions (on the newly created site) -> Grant Permission -> search for groups in the parent site and then grant permission for this group. So, in the parent site myGroup can have Full Access permissions but in this site I can set it to Contribution or whatever. Is it possible to do this when I create the site or just after (programmatically)?

share|improve this question

2 Answers 2

Another great references can be found here:

Just remember: if you want to use a Feature Event Receiver, you should change feature activation of the solution (solution properties) to "Without activation", and to be able to deploy the Feature Event Receiver, set the Sandbox deployment to false.

share|improve this answer

Your Answer


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