Currently trying to implement the behaviour to change the roles for the default Groups in Sharepoint (Owner, Member, Viewer). Goal is to set the Member roles to only "view". I found this Documentation.
My Code:
await pnpContext.Web.LoadAsync(p => p.SiteGroups.QueryProperties(u => u.Users));
var roleDefinitions = (await pnpContext.Web.GetAsync(p => p.RoleDefinitions)).RoleDefinitions;
var editRole = roleDefinitions.AsRequested().FirstOrDefault(p => p.Name == "Edit");
foreach (var group in pnpContext.Web.SiteGroups.AsRequested())
{
var currentRole = await group.GetRoleDefinitionsAsync();
//Error in if statement: Cannot convert IRoleDefinition to Bool
if (currentRole.AsRequested().FirstOrDefault(p=>p.Name == "Full Control"))
{
await group.RemoveRoleDefinitionsAsync(editRole.Name);
}
}
Build it exact same way as in the documentation. Can't find a solution to this. Any Ideas?