Portal Engine Questions on portal engine and web parts.
Version 7.x > Portal Engine > custom user menu - check permissions View modes: 
User avatar
Member
Member
cucumber-carol - 11/10/2013 4:59:31 PM
   
custom user menu - check permissions
I have created a custom navigation menu, and I am trying to check permissions to see if the user has access to that document / node in order to be able to hide or display a particular menu item. I have tried many different ways:
CMSContext.CurrentUser.IsAuthorizedPerObject(PermissionsEnum.Read, node,CMSContext.CurrentSiteName)

node.CheckPermissions(PermissionsEnum.Read,CMSContext.CurrentSiteName,CMSContext.CurrentUser)

TreeSecurityProvider.IsAuthorizedPerNode(node, NodePermissionsEnum.Read, CMSContext.CurrentUser) == AuthorizationResultEnum.Allowed

DocumentSecurityHelper.IsAuthorizedPerDocument(node,NodePermissionsEnum.Read,true,CMSContext.CurrentDocumentCulture.CultureCode,CMSContext.CurrentUser)==AuthorizationResultEnum.Allowed

and they all return false.

How do I check to see if the current user has permission to view a node or document front of site?

User avatar
Member
Member
cucumber-carol - 11/10/2013 5:01:05 PM
   
RE:custom user menu - check permissions
full code:
var nodes = TreeHelper.SelectSingleNode("/");
var menuNodes = (from node in nodes.Children
where (node.GetBooleanValue("DocumentMenuItemHideInNavigation", true) == false) && (node.IsPublished) && (DocumentSecurityHelper.IsAuthorizedPerDocument(node,NodePermissionsEnum.Read,true,CMSContext.CurrentDocumentCulture.CultureCode,CMSContext.CurrentUser)==AuthorizationResultEnum.Allowed)
select new MenuNode(node));
TopNav.DataSource = menuNodes;
TopNav.DataBind();