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

Forums / Developing with Sitefinity / Show search results based on user permission

Show search results based on user permission

4 posts, 0 answered
  1. Gpl
    Gpl avatar
    7 posts
    Registered:
    17 Dec 2008
    15 Jan 2010
    Link to this post
    Hi,

    I am using Sitefinity v 3.7. When logged-in users perform a search, I want only the content they have been permitted access to be displayed in the search results. Is this possible?

    Regards
    Gpl
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    15 Jan 2010
    Link to this post
    .Hi Gpl,

    You can access the search result item from ~/Sitefinity/ControlTemplates/Search/SearchResult.ascx repeater. Then you need to loop through each ResultItem, extract the item ID from the snippet and call CmsManager GetPage method where you pass the ID.
    Finally call CheckDemand to see whether the currently logged in user have at least view permissions.

    var cmsManager = new CmsManager();
    ICmsPage page = (ICmsPage)cmsManager.GetPage(pID);
    PagePermission perm = new PagePermission(page);
     if (perm.CheckDemand(CrudRights.View))
      {
     
      }

    For IContent objects you have to work only with the provider. The current implementation does not expose permissions per ICotenent item.

    Regards,
    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.
  3. antoniodlp
    antoniodlp avatar
    13 posts
    Registered:
    28 Mar 2007
    17 Apr 2010
    Link to this post
    Sorry, how can you extract the item ID from the snippet???
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    18 Apr 2010
    Link to this post
    Hello raindogmx,

    You could take a look at this post.

    Regards,
    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