开发者

Umbraco Node Permissions

开发者 https://www.devze.com 2023-02-06 15:42 出处:网络
I have searched for hours and not found the answer to this, so was hoping so开发者_Python百科meone here could help.

I have searched for hours and not found the answer to this, so was hoping so开发者_Python百科meone here could help.

How do I get the roles set on a node from code behind?

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

How do I now know what role permissions are set on this node?

Thanks in advance.


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

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

or simpler if you do not want to manually check the roles assigned you can check against the membershipuser

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


In Umbraco (after 4.7) we can simply 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

精彩评论

暂无评论...
验证码 换一张
取 消