So far I am able to grant user certain permission with the following code:
ClientContext context = new ClientContext("http://myRealURL");
Principal user = context.Web.EnsureUser(@"myLoginAccout");
RoleDefinition readDef = context.Web.RoleDefinitions.GetByName("Read");
RoleDefinitionBindingCollection roleDefCollection = new RoleDefinitionBindingCollection(context);
roleDefCollection.Add(readDef);
RoleAssignment newRoleAssignment = context.Web.RoleAssignments.Add(user, roleDefCollection);
context.ExecuteQuery();
The code above works fine, now my task is to add the user permission only to certain folders with C# code. For example, under Libraries, I have a library called JZhu
, and inside JZhu
, I have two folders folder1
and folder2
. Is it possible to change the access permission on these two folders with Client Object Model
?