Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sitecore Item Access Rights

Tags:

sitecore

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?

like image 892
Mohammed Syam Avatar asked Mar 15 '23 01:03

Mohammed Syam


1 Answers

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;
    }
}
like image 146
Jan Bluemink Avatar answered Mar 20 '23 02:03

Jan Bluemink