I need to loop through all RoleDefinitiona of ProjectSite and get all users related to each one and add those users to a RoleDefinition of a ProjectSite in another SiteCollection
I can loop through RoleDefinitions like :
using (var src_ctx = new ClientContext(Root))
{
RoleDefinitionCollection role_definition_collection = src_ctx.Web.RoleDefinitions;
src_ctx.Load(role_definition_collection);
src_ctx.ExecuteQuery();
foreach (RoleDefinition role_definition in role_definition_collection)
{
}
}
also I can loop through all groups and read users of each group then get RoleAssignment of each user:
GroupCollection group_collection = src_ctx.Web.SiteGroups;
src_ctx.Load(group_collection);
src_ctx.ExecuteQuery();
foreach (Group group in group_collection)
{
UserCollection user_collection = group.Users;
foreach (User user in user_collection)
{
RoleAssignment role_assignment = src_ctx.Web.RoleAssignments.GetByPrincipal(user);
RoleDefinitionBindingCollection role_definition_binding_collection = role_assignment.RoleDefinitionBindings;
}
}
but how can I link between RoleDefinition and users ?