How can I set up a Lucene index in Sitecore that handles security correctly?

核能气质少年 提交于 2019-12-12 05:44:05

问题


I have a number of different roles in Sitecore. And I have set security permissions on my content items so that different roles can only access certain content items. It seems that Lucene will just index all of the content. And when I query Lucene it doesn't pay any attention to the security. Is there any way to get Lucene to only return items that the current Extranet user has access to?

Thanks, Corey


回答1:


Not to my knowledge. But when working through the Hits collection, you would normally have a loop similar to this:

for ( int i = 0; i < hits.Length() && i < Context.Current.Settings.MaxSearchResultsToProcess; i++ )
{
    Item item = Index.GetItem( hits.Doc( i ), Context.Current.Database );
    if ( item != null )
    {
        indexResultater.Add( item );
    }
}

And since this runs in context of your current user, no results would be added to your results if the user cannot access them.



来源:https://stackoverflow.com/questions/4108781/how-can-i-set-up-a-lucene-index-in-sitecore-that-handles-security-correctly

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!