+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / Finding accessible pages from a console application

Finding accessible pages from a console application

4 posts, 0 answered
  1. Lucas
    Lucas avatar
    65 posts
    Registered:
    22 Mar 2010
    24 Aug 2010
    Link to this post
    Hi,

    I'm developing a feature that allows users to register to a page and receive a daily digest of all changes that happened in the last 24 hours. I'm willing to create a batch that will not run on the web server.

    The major bump in the road will be to be able to retrieve the SiteMap for a particular user: I don't want them to able to register to a page they don't have access to, and more importantly, I don't want them to receive updates for a page they can no longer view.

    That means that I need to check if a user can access the page before sending the alert. Is there an easy way, to achieve this?
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    24 Aug 2010
    Link to this post
    Hi Lucas,

    Get the page and check its permissions as shown below

    var manager = new CmsManager();
    var pagePerm = new PagePermission(cmsPage, PageRights.View);
    bool canViewPage = pagePerm.CheckDemand();


    Sincerely yours,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. Lucas
    Lucas avatar
    65 posts
    Registered:
    22 Mar 2010
    24 Aug 2010
    Link to this post
    Mmm, I'm guessing CheckDemand checks the permission for the current user ? Is there a version that accepts a username in order to check if someone else can access the page?

    As a related note, manager.GetPage(pageId) returns an IPage. Is it possible to translate that IPage into a ICmsPage? (I'm in a console application, I don't have access to the sitemap)
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    24 Aug 2010
    Link to this post
    Hello Lucas,

    1. You can take a look at this post where I explained how to check page permissions based on a role. Page permissions and content permissions are role based,.

    2.You can cast the IPage to ICmsPage when you call GetPage();

    Best wishes,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Register for webinar
4 posts, 0 answered