I’m trying to test this code snippet but I get the “Missing a using directive or an assembly reference” error on “ClientContext oContext = new ClientContext(siteUrl);” I’m copying and pasting directly from the Microsoft site so I’m not sure what am I missing…
using System;
using Microsoft.SharePoint.Client;
using SP = Microsoft.SharePoint.Client;
namespace Microsoft.SDK.SharePointServices.Samples
{
class BreakSecurityInheritance
{
static void Main()
{
string siteUrl = "http://MyServer/sites/MySiteCollection";
ClientContext oContext = new ClientContext(siteUrl);
SP.List oList = oContext.Web.Lists.GetByTitle("Announcements");
oList.BreakRoleInheritance(true, false);
oContext.ExecuteQuery();
}
}
}
As said earlier, you need a reference to the SharePoint client object model. Luckily, you can get those from Microsoft as part of the SP Client OM redistributable without having to install a full local SharePoint server.
http://www.microsoft.com/download/en/details.aspx?id=21786