Hi,
I want to get the user permissions of every document files in sharepoint online using csom c# so that I will be able to restore files with the correct user permissions.
Right now, I did it like this
List Lists = clientContext.Web.Lists.GetByTitle("Documents");
CamlQuery Query = CamlQuery.CreateAllItemsQuery(100);
ListItemCollection Items = Lists.GetItems(Query);
clientContext.Load(Items, item => item.Include(i => i.DisplayName, i => i.File, i => i.RoleAssignments.Include(roleAsg => roleAsg.Member, roleAsg => roleAsg.RoleDefinitionBindings.Include(roleDef => roleDef.Name, roleDef => roleDef.Description))));
clientContext.ExecuteQuery();
loginNames = new Dictionary<string, List<string>>();
foreach (ListItem litem in Items)
{
List<string> roles = new List<string>();
foreach (RoleAssignment role in litem.RoleAssignments)
{
roles.Add(role.Member.LoginName);
}
loginNames.Add(litem.File.Name, roles);
}
But this will retrieve the role assignments of files stored in Documents. But, along with files, sub folders will be there which also have files and again subfolders. I want role assignments of these files in nested subfolders also. How to get it.
Thanks,
Palak