I am working with SharePoint 2010.

I am trying to assign existing group to the folder in Document Library using Client Side Object Model C#.

I found this code in answer. This works but it ask for RoleType and I don't want to specify any RoleType.

I just want to assign the group permission to my folder in Document Library without specifying RoleType externally because I want to assign the existing permission of group to folder.

So I need help for these.

2 Answers 2


With the help of answer by @Ankit Kumar, I tried the code given here. But his code is for SharePoint 2013. And the question is for SharePoint 2010.

In SharePoint 2010 var GRoup1 = cpx.Web.SiteGroups.GetByName(groupName); will always gives error

Method "GetByName" does not exist.

So I modified the code to get the group name as shown below:

Group grp = null;
GroupCollection groupColl = clientContext.Web.SiteGroups;
    groups => groups.Include(
    group => group.Title,
    group => group.Id));
foreach (Group siteGroup in groupColl)
    if (siteGroup.Title.Equals("TestGroup"))
        grp = siteGroup;

And after that using following code I was able to implement this on my SharePoint 2010 Environment.

var roletypes = clientContext.Web.RoleDefinitions.GetByType(RoleType.Contributor);
listItemObject.BreakRoleInheritance(true, false);
RoleDefinitionBindingCollection collRoleDefinitionBinding = new RoleDefinitionBindingCollection(clientContext);
listItemObject.RoleAssignments.Add(grp, collRoleDefinitionBinding);

Where listItemObject is your folder context. This code worked for me at my 2010 Environment.

Let me know if this solved your problem or any further help needed.


So basically you are not trying to break the inheritance. Did you try by keeping folder.BreakInheritance as false.or if you exclude this line :

collRoleDefinitionBinding.Add(clientContext.Web.RoleDefinitions.GetByType(RoleType.Reader)); //Set permission type

Also check this. here if you pass role types as null. Assign Unique permission to SharePoint 2013 List using Client Side code C#

  • I am already able to use this code properly, But the group already have the permission, So I don't want to specify the role type. I just want to assign the group without specifying the role type. Is it possible? Aug 5, 2016 at 4:06
  • yeah thats mean u r going to inherit the permission from parent. Thats what I have asked you to check above. Aug 5, 2016 at 7:04
  • I need for 2010. I am using Microsoft.SharePoint.Client of version v14. Aug 5, 2016 at 13:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.