I want to check if a sitecore item has any access rights applied or not so I am thinking of checking if the security field has a value i.e
item.Fields["__Security"].Value
Is this is the correct way of checking if an item has access rights or Is there another way of doing this?
Yes, in the __Security Field are the rights stored.
You can use: item.Security.GetAccessRules();
var accessRules = item.Security.GetAccessRules();
if (accessRules != null)
{
foreach (var rule in accessRules)
{
var name = rule.Account.Name;
var comment = rule.AccessRight.Comment;
var permiss = rule.SecurityPermission;
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With