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 :/



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


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);



Your Answer

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

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