Home > sharepoint, sharepoint 2010 > Programmatically managing Item-level Permissions in SharePoint 2010

Programmatically managing Item-level Permissions in SharePoint 2010

January 17th, 2010
Share this on Twitter

In SharePoint 2010 you get an ability to set item level permissions on items in a list or library, here is how UI in Advanced Settings of the list looks like:

item level permissions

If you’re defining your site through a schema or definition you probably want to know how all of those settings are set through the code, and here’s how:

First, the Read Access  option is toggled Read all items or Read items that were … to set that you will write something like this:

SPList list = SPContext.Current.Web.Lists["MyList"];
list.ReadSecurity = 1;

The value of ReadSecurity will be either 1 or 2 as per msdn article.

Now the second option that will determine permissions to edit items will look somethig like this:

SPList list = SPContext.Current.Web.Lists["MyList"];
list.WriteSecurity= 1;

Here the value will be 1, 2 or 4 depending on the option that you can check out here at msdn.

Very usefull two options that back in MOSS days I had to write event receiver for, now available out of the box!

Yaroslav Pentsarskyy sharepoint, sharepoint 2010 , , , ,

You must be logged in to post a comment.