SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top


When a User (let say Controller 1) creates a site using a site definition, "which already has a Custom List definition in it and different other things(like lists, webparts)"

Custom List: what it does is, You can create a item and assign it to any other controller or yourself.

Question: So what I want is, When the Site is being created, I just want to give "add New Items" / Edit List Items permission for that specific list to Controller 1 or the Controller "n" he gave permission for that specific site.

I know I need to add code somewhere while creating the site, but dunno how I gonna do that in this context :/


share|improve this question
up vote 2 down vote accepted

I'm not 100% sure which users should be allowed to do what, but if you need to give difference Controllers control of difference list items then you could look at Setting item level security in an eventhandler

share|improve this answer

Here's an example of code I wrote to change the permissions on a list. This isn't list items, but you can probably figure out how to do that part :)

    SPList splDocuments = spwWeb.Lists["Documents"];
    string strGroup = "[The name of your group]";
    RemoveAllPermissions(splDocuments, strGroup);

And then these functions:

    private SPPrincipal GetPrincipal(SPSite spsSite, string strGroupName)
        SPPrincipal sppGroup = null;

        if (SPUtility.IsLoginValid(spsSite, strGroupName))
            sppGroup = spsSite.RootWeb.EnsureUser(strGroupName);
            foreach (SPGroup spgGroup in spsSite.RootWeb.SiteGroups)
                if (spgGroup.Name.ToUpper(CultureInfo.InvariantCulture) ==
                    sppGroup = spgGroup;
        return sppGroup;

    private void RemoveAllPermissions(SPList splList, string strGroupName)
        SPPrincipal sppPrincipal = GetPrincipal(splList.ParentWeb.Site, strGroupName);
        SPRoleAssignment spraRoleAssignment = splList.RoleAssignments.GetAssignmentByPrincipal(sppPrincipal);


share|improve this answer

Your Answer


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

Not the answer you're looking for? Browse other questions tagged or ask your own question.