R – Changing SPList Inherit Parent Permissions property using C#

sharepointsharepoint-2007sharepoint-api

I have a Document Library for which I need to add a user (SPRoleAssignment object). But since the SPList inherits the Roles from the parent web, it does not allow me to add for this SPList object alone. To add SPRoleAssignment object to this list alone, there is an option in UI, to create a separate copy of permissions for this SPList object alone. But how do I do this using a C# program?

Best Answer

Take a look at the SPList.BreakRoleInheritance method.

yourList.BreakRoleInheritance(true);

You can pass true to copy the role assignments from the parent Web site, or pass false to add the current user to the permission level required to manage the list.

Related Topic