Wednesday, December 9, 2009

Set Item level permission in Sharepoint Document Library

In Documnet library, we can not set item level permission by using Sharepoint Document Library Settings (unlike sharepoint List Settings). There is a very simple code snippet which does the same for us.

Code snippet

using (SPSite spSiteObje = new SPSite("http://SiteColName/Subsite"))
{
using (SPWeb spObjWeb = site.OpenWeb())
{
SPList spObjDocLib = web.Lists["MyDocLib"];
spObjDocLib.ReadSecurity = 2;
spObjDocLib.WriteSecurity = 2;
spObjDocLib.Update();
}
}

No comments: