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

Forums / Security / Search results by role

Search results by role

6 posts, 0 answered
  1. antoniodlp
    antoniodlp avatar
    13 posts
    Registered:
    28 Mar 2007
    17 Apr 2010
    Link to this post
    Hi,

    I know there are some other threads regarding this but so far I haven't found an answer in them to my particular problem.

    The problem is that in this site, the administrators add roles liberally and assign permissions to documents as they see fit, i.e. not always on a root level. We have catered for this on the listings by trimming them using the properties and methods in the CmsContentBase object; but we can't do this with search results, as you know.

    So, we do want to go the route of parsing the search results to make sure the current user has access to each of them but I haven't found an efficient way to do it. I already understand performance may be severely compromised but what I intend to do is have a public-only index for anonymous users and a full index for authenticated users and only apply the filtering to those results.

    Option B is to index permissions as well but I think that would be very complex. I have read the documentation, tutorials and posts on making custom indexers and I guess that would be the way to go about this but haven't fully understood what's involved.

    I guess what I'm asking for here is for some code examples on the most efficient way to check permissions based on the data available in the ResultItem object.

    Thank you
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    18 Apr 2010
    Link to this post
    Hello raindogmx,

    Here is a link to a forum post that shows how to access the result item. Once you access the object ( page, content item etc) you can use UserManager class to get the current user.

    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.
  3. antoniodlp
    antoniodlp avatar
    13 posts
    Registered:
    28 Mar 2007
    22 Apr 2010
    Link to this post
    Hi Ivan,

    Thank you for your reply. I've been spending a couple of days on this and found that adding the guid to the index is not very reliable as many times the guid doesn't come back with the snippet.

    Do you have any suggestion? I was trying to put it into the title instead...
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    22 Apr 2010
    Link to this post
    Hello raindogmx,

    If  you have unique titles, use them as unique key to get the items.

    Kind 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.
  5. Laura
    Laura avatar
    311 posts
    Registered:
    25 Feb 2008
    12 May 2010
    Link to this post
    Hopefully you can provide me with a quick answer as I need to get back to our vendor. Is there a way to provide search results based on the role the user has when logged in?   In our case - some pages may be visible to one or more roles.  When a user does a search from a search box that is in a template used by all pages, we would like the results to be tailored to their role, returning not only the public pages but also any pages that they have access to for their given role. 

    1) Is this possible?
    2) What is the big picture in the process of this? I read somewhere I would need a different search control on the different pages depending on the search service being used but what if they just search from the home page?

    Thank you in advance!
  6. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    12 May 2010
    Link to this post
    Hi Laura,

    You should create a custom SearchResults control and filter the results based on the currently authenticated user. You should override CreateChildControls method and get all ResultsItems that are added to the index. Then loop through each item and check whether the current user has permissions to this page, create a new list and bind the SearchResults repeater to a new datasource. Note that there could be some performance issues. You could see a sample code how to override the default behavior of the control in this post - Multiple search result controls

    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.
Register for webinar
6 posts, 0 answered