Try Now
More in this section

Forums / Security / Check if user can view a CMS Page ID

Check if user can view a CMS Page ID

2 posts, 1 answered
  1. James Reategui
    James Reategui avatar
    22 posts
    14 Oct 2008
    08 Sep 2009
    Link to this post
    I thought this would be simple but haven't found an easy solution in the forums.

    I have a page id coming in as: [Sitefinity]GUID and wish to check if the current user, or a preferebly a membership user object, has permissions to View that page. Do I have to compare the roles, if so how do I get the roles assigned to a page?

  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    25 Oct 2016
    08 Sep 2009
    Link to this post
    Hello James,

    Below is a sample code that illustrate how to check whether the current user has View permissions for a specific page.

             ICmsPage currentPage = (ICmsPage)manager.GetPage(new Guid("58114CAC-EF9D-48c7-AF70-5E20948EED91")); 
            PagePermission perm = new PagePermission(currentPage); 
            // this checks whether the current user has View permissions. 
            if (perm.CheckDemand(PageRights.View)) 
                //do something 

    All the best,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
2 posts, 1 answered