Umbraco Node Permissions

I was looking for a watch and could not find an answer to this question, so I was hoping that someone here could help.

How do I get the roles installed in node from code?

I have my node: Node nodeToCheck = new Node(nodeID);

How now to find out what permissions are set on this node?

Thanks in advance.

+4
source share
2 answers

I just found out how to do this, so I thought I would report here:

 string[] roles = Access.GetAccessingMembershipRoles(int.Parse(nodeID), nodeToCheck.Path); 

or simpler if you do not want to manually check the assigned roles that you can check against user-user

 bool hasAccess = Access.HasAccess(int.Parse(nodeID), nodeToCheck.Path, MembershipHelper.GetCurrentUser()); 
+11
source

In Umbraco (after 4.7) we can just do

 node.HasAccess // this tells you if the current user has access to that node 

Before that we had

 node.HasAccess() // or something like that.. 
0
source

Source: https://habr.com/ru/post/1337127/


All Articles