views:

407

answers:

1

Hi,

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?

+6  A: 

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.

Magnus Johansson