Is there a way to check if a specific user role has been granted read permission to a specific item?
I've tried using item.Security.CanRead(role)
but to no success (this returns true
when I'd expect false
).
Edit:
May have been a bit premature with this, I seem to be able to achieve it with;
foreach(var role in roles)
{
var accessRules = item.Security.GetAccessRules();
foreach (var accessRule in accessRules)
{
if (accessRule.Account == role && accessRule.AccessRight == Sitecore.Security.AccessControl.AccessRight.ItemRead)
{
return true;
}
}
}
but any more succient methods would be good!