Quantcast
Channel: SharePoint 2013 - Development and Programming forum
Viewing all articles
Browse latest Browse all 7589

Remove SharePoint Groups from a SharePoint list with Unique permission

$
0
0

I am trying to create unique permission in a SharePoint list using client side C# code. I am able to break inheritance and add a permission level to the group, but the thing is it is getting added to the permission level. For example if i have an owner group and I have full control from the site, once i break permission for a list and assign read permission to the Owner group, I get both Full Control and Read permission for the group. I would like to know if there is a way if i can remove all the permission from the group before adding my own groups and permisssion.

below is the code:

 public static void AddPermission(ClientContext cpx, List list, string groupName, RoleDefinition rdef)
 {
  try {
   var GRoup1 = cpx.Web.SiteGroups.GetByName(groupName);
   list.BreakRoleInheritance(true, false);
   list.Update();
   cpx.Load(list);
   cpx.ExecuteQuery();
   RoleDefinitionBindingCollection collRoleDefinitionBinding = new RoleDefinitionBindingCollection(cpx);
   collRoleDefinitionBinding.Add(rdef);
   list.RoleAssignments.Add(GRoup1, collRoleDefinitionBinding);
   cpx.ExecuteQuery();
  } catch (Exception ex) {

  }
 }


zzzSharePoint



Viewing all articles
Browse latest Browse all 7589

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>