using Microsoft.SharePoint; using System; namespace SharePointPermissions { class Program { static void Main(string[] args) { string listUrl = "https://your-sharepoint-url.com/Lists/YourList"; int itemId = 1; using (SPSite site = new SPSite(listUrl)) { using (SPWeb web = site.OpenWeb()) { var listItem = web.Lists.TryGetList("YourList").GetItemById(itemId); if (listItem.HasUniqueRoleAssignments == false) { listItem.BreakRoleInheritance(false, true); } Console.WriteLine("List item permissions have been updated"); } } Console.ReadLine(); } } }
using Microsoft.SharePoint; using System; namespace SharePointPermissions { class Program { static void Main(string[] args) { string listUrl = "https://your-sharepoint-url.com/Lists/YourList"; int itemId = 1; using (SPSite site = new SPSite(listUrl)) { using (SPWeb web = site.OpenWeb()) { var listItem = web.Lists.TryGetList("YourList").GetItemById(itemId); if (listItem.HasUniqueRoleAssignments == false) { listItem.BreakRoleInheritance(true, true); } Console.WriteLine("Item permissions have been reset to the parent object's permissions"); } } Console.ReadLine(); } } }This example breaks inheritance for an item with ID of 1 in a list called "YourList" and resets the permission to the parent object's permission. Package library: Microsoft.SharePoint.