Sitecore Element Permissions

I want to check whether the sitecore element has any permissions or not, so I want to check if the security field has ie

item.Fields["__Security"].Value 

Is this the right way to check the permissions of an element, or is there another way to do this?

+4
source share
2 answers

Yes, the rights are reserved in the __Security field.

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; } } 
+5
source

This kind of thing is more like API ish

 foreach(Role role in RolesInRolesManager.GetAllRoles()) { bool hasReadAccess= itemUnderTest.Security.CanRead(role); } 

In fact, take a look at all the methods of Item.Security

+2
source

All Articles