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

Item level permission from it's native parent. We convert files are uploaded by end user to png put it in "PNG" folder of that document library. There are bunch of other folders (_Private, PNG, Public, Finance, HR) within a document library (including png folder which has read access to all the custom groups).

When HR uploads a file (i.e. payroll.xls) into their folder "HR" then it gets rendered to PNG format (payroll.png). Rendered file resides in the PNG folder. I like to inherit permission from HR folder and apply it on the rendered png file so that only HR can see payroll.png when HR go to "PNG" Folder. The file should not be visible by unintended group(s).

Hope it's making sense.

share|improve this question

Here is the code that copies security from source item to target item where target item resides in another folder within the same document library

private void InheritPermission(Guid siteID, Guid webID, Guid ListID, int SourceItemID,  int ImageItemID )
    using (SPSite site = new SPSite(siteID))
        using (SPWeb web = site.OpenWeb(webID))
            SPList list = web.Lists[ListID];
            SPListItem SourceItem = list.GetItemById(SourceItemID);
            SPListItem ImageItem = list.GetItemById(ImageItemID);

if (!ImageItem.HasUniqueRoleAssignments) { ImageItem.BreakRoleInheritance(true); } SPRoleAssignmentCollection ImageItemRoles = ImageItem.RoleAssignments; //Removing all the default groups while (ImageItemRoles.Count > 0) ImageItemRoles.Remove(0); SPRoleAssignmentCollection SourceItemRoles = SourceItem.RoleAssignments; foreach (SPRoleAssignment SourceRole in SourceItemRoles) { ImageItem.RoleAssignments.Add(SourceRole); } ImageItem.Update(); } }

}); }

share|improve this answer

You would have to break role inheritance on the item placed in the PNG folder. You would then have to manually add the same security to the item that the HR folder items have.

The easiest way to do this is add the PNG to the HR folder first, then call SPListItem.BreakRoleInheritance(true). This will copy the permissions to the item. Then I would move the item to the PNG folder.

share|improve this answer
  1. You would need to have an event receiver on your library coded to operate when an item of the type PNG is added under the PNG folder.(OR you can add the logic below to the same code which creates this item under PNG folder.)
  2. Further on the ItemAdded event get the RoleAssignment of any file in the HR folder.
  3. On the newly created item under PNG folder, break the RoleInheritance and then add role assignment from #3 to the same.
share|improve this answer

Your Answer


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