Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Matt Taylor 873 posts 2086 karma points
    Jan 22, 2013 @ 13:15
    Matt Taylor
    1

    Examine Indexer setting - supportProtected

    When configuring an Examine Indexer you can set the value of the supportProtected attribute.

    The only documentation I can find about this setting is:

    "Set to true if you want protected content indexed"

    From this I'm assuming that it is referring to content that has been protected by membership restrictions.

    Is that right?

    Regards,

    Matt

  • Ismail Mayat 4511 posts 10092 karma points MVP 2x admin c-trib
    Jan 22, 2013 @ 14:43
    Ismail Mayat
    0

    Matt,

    It is. Out of the box protected content will not be indexed.

    Regards

    Ismail

  • Matt Taylor 873 posts 2086 karma points
    Jan 22, 2013 @ 15:27
    Matt Taylor
    0

    Thanks Ismail,

    So am I right in thinking that it is smart enough to look at the user that is logged in, determine which roles they have and only return content that they have persmission to view?

    Cheers,

    Matt

  • Ismail Mayat 4511 posts 10092 karma points MVP 2x admin c-trib
    Jan 22, 2013 @ 15:33
    Ismail Mayat
    1

    Matt,

    As far as I am aware no.  However what you can do is implement GatheringNodeData event and inject into a field (e.g field called GroupAccess) member groups that are allowed to view that content. Then as part of your search filter you can apply that currently logged in users group membership and filter on that. That way you can only show those results he/she has access to. For non protected content you will need to put in some value (e.g public in to GroupAccess field) and use that as part of query.

    Regards

    Ismail

  • Mike Chambers 636 posts 1253 karma points c-trib
    Mar 14, 2013 @ 12:50
    Mike Chambers
    0

    Ismail do you have a coded example of how to implement the GatheringNodeDate event to inject the member groups in to the index?

  • Ismail Mayat 4511 posts 10092 karma points MVP 2x admin c-trib
    Mar 14, 2013 @ 13:00
    Ismail Mayat
    0

    Mike,

    In umbraco.library there are some methods you can use eg

                    umbraco.library.IsProtected(10,path);

                   umbraco.library.AllowedGroups(10,path)

    Replace 10 with actual id of node this you can get in gatheringnode node data from the IndexingNodeDataEventArgs e object. The path is either from node or document object you will need to instantiate one or the other and that has path property.

    Regards

    Ismail

  • Mike Chambers 636 posts 1253 karma points c-trib
    Mar 14, 2013 @ 13:03
    Mike Chambers
    0

    So you mean set the extenal indexer to supportProtected="true"  and then filter the result set from examine.. result by result.

    Thought you were injecting into the actually examine index so you could query it at the index level to exclude results I shouldn't see.

  • Ismail Mayat 4511 posts 10092 karma points MVP 2x admin c-trib
    Mar 14, 2013 @ 13:12
    Ismail Mayat
    1

    Mike,

    Yes you have to set supportProtected to true so that the content is in the index. Also as part of the indexing process inject in the allowed groups for that content then you can use examine to filter those results. So as you build your query get the logged in user and the group he/she belongs to then include that as part of filter i.e query.And().Fields("groups",currentMemberGroup) 

    Regards

    Ismail

     

  • Mike Chambers 636 posts 1253 karma points c-trib
    Mar 14, 2013 @ 13:52
    Mike Chambers
    0

    so the bit I am missing... is how do i add the "groups" field to the default externalindex that ships with 4.11.5???

  • Ismail Mayat 4511 posts 10092 karma points MVP 2x admin c-trib
    Mar 14, 2013 @ 14:25
    Ismail Mayat
    0

    You implement gatheringnodedata event and use the two methods 

     

        umbraco.library.IsProtected(10,path);

                   umbraco.library.AllowedGroups(10,path)

    If current document you are indexing is protected then get the allowed groups and inject those in. See here for some sample gatheringnode data code it does not have member stuff but you can use and put the member stuff in.

    Regards

    Ismail

     

  • David Conlisk 432 posts 1008 karma points
    Jul 04, 2013 @ 12:43
    David Conlisk
    0

    Hi Ismail,

    My Examine adventures continue! I'm trying to implement this exact idea. However, I've run into a problem. When I call umbraco.library.IsProtected in my GatheringNodeData method, I get an exception:

    Value cannot be null. Parameter name: umbracoContext

     

    So it looks like you need an umbraco context which doesn't exist when my GatheringNodeData runs. Any ideas on how to get around this? Am I missing something? My code is basic:

    private void indexer_GatheringNodeData(object sender, IndexingNodeDataEventArgs e)        
    {
                //Log.Add(LogTypes.Debug, 1, String.Format("Gathering Node Data: {0}", e.Fields["nodeName"]));
                var n = new Node(e.NodeId);
                if (umbraco.library.IsProtected(n.Id, n.Path))// EXCEPTION THROWN HERE!
                {
                    var groups = umbraco.library.AllowedGroups(n.Id, n.Path);
                }
    }

    Cheers!

    David

  • David Conlisk 432 posts 1008 karma points
    Jul 04, 2013 @ 12:50
    David Conlisk
    1

    I found this post: Umbraco Examine protected pages which says to use

    umbraco.cms.businesslogic.web.Access.IsProtected(int.Parse(e.Node.Attribute("id").Value), e.Node.Attribute("path").Value);

    instead. You'll need to ensure you have a reference to cms.dll in your project.

  • Ismail Mayat 4511 posts 10092 karma points MVP 2x admin c-trib
    Jul 04, 2013 @ 13:13
    Ismail Mayat
    0

    David,

    Awesome. Totally forgot about that one.

    Regards

    Ismail

Please Sign in or register to post replies

Write your reply to:

Draft