Help shape the future of CMS PaaS release notes! Take this quick survey and share your feedback. 

CMS 12 + Lucene Content search

Vote:
 

I have an issue with viewing lucene content search results on a site with windows authentication. It seems like I can see results on the search page when I have WebEditors or WebAdmins access right. But I cant see the search result when i'm an Everyone user. Does anyone know why?

 

Im using the github episerver content search lucene project as search service

 

 

 

#336368
Edited, Feb 03, 2025 9:26
Vote:
 

This may depend on your site settings, how is the default site setup in site management?

E.g.

#336406
Feb 04, 2025 8:06
Vote:
 

Thanks for your answer, this is what the site settings look like:

 

Any suggestion what to change?

 

Thanks, 

Magnus

#336441
Feb 05, 2025 9:06
Vote:
 

Can "everyone" authenticated (I assume Authenticated Users) access the site since it is an Intranet? 

Assuming that searches always will be in authenticated context have you implemented AccessControlListQuery. Ted Nygren wrote this a while ago that maybe will help you out, Add custom fields to the EPiServer Search index with EPiServer 7 - ted&gustaf

The cleaned up version would look like this

public IEnumerable<T> Search<T>(string keywords) where T: IContent 
{
	// We'll combine several queries and all must match 
	var query = new GroupQuery(LuceneOperator.AND); 

	// Only search for content of type T 
	query.QueryExpressions.Add(new ContentQuery<T>());
	query.QueryExpressions.Add(new FieldQuery(keywords));

	// Only search for content the current user has permission to read 
	var accessQuery = new AccessControlListQuery();
	accessQuery.AddAclForUser(PrincipalInfo.Current, HttpContext.Current);
	query.QueryExpressions.Add(accessQuery);

	// Perform search 
	var searchHandler = ServiceLocator.Current.GetInstance<SearchHandler>();
	var results = searchHandler.GetSearchResults(query, 1, int.MaxValue);
	var contentSearchHandler = ServiceLocator.Current.GetInstance<ContentSearchHandler>();

	// Convert search result to pages 
	return results.IndexResponseItems.Select(contentSearchHandler.GetContent<T>);
}

Try adding the ACL-stuff to your searches and see if that resolves the issue

#336442
Edited, Feb 05, 2025 9:54
Vote:
 

Thanks for the hint in right direction, I got it working by setting specific roles access like this:

 

accessRightsQuery.AddRole(EveryoneRole.RoleName);
accessRightsQuery.AddRole(AuthenticatedRole.RoleName);

 

and skipped this part:

accessRightsQuery.AddAclForUser(context);

 

/M

#336474
Edited, Feb 06, 2025 13:04
Eric Herlitz - Feb 06, 2025 13:05
Awesome, please mark an answer as correct and we'll get the thread closed!
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.