Umbraco Examine - incorrect supportProtectedConten...
# help-with-umbraco
r
We are using umbraco 13 with Examine. trying to set the SupportProtectedContent Property on my external index to true. But when inspecting in the cms the value is set to false. Current config setup code: public class ConfigureExternalIndexOptions : IConfigureNamedOptions { private readonly IPublicAccessService _publicAccessService; private readonly IScopeProvider _scopeProvider; public ConfigureExternalIndexOptions(IPublicAccessService publicAccessService, IScopeProvider scopeProvider) { _publicAccessService = publicAccessService; _scopeProvider = scopeProvider; } public void Configure(string name, LuceneDirectoryIndexOptions options) { if (name.Equals(Constants.UmbracoIndexes.ExternalIndexName)) { options.Validator = new ContentValueSetValidator(true, true, _publicAccessService, _scopeProvider, null, null); } } }****
j
You an overwrite the default index config: https://github.com/umbraco/Umbraco-CMS/blob/contrib/src/Umbraco.Infrastructure/Examine/UmbracoIndexConfig.cs
Copy code
csharp
public class RestrictedContentIndexConfig : IUmbracoIndexConfig
{
    private readonly IPublicAccessService _publicAccessService;
    private readonly IScopeProvider _scopeProvider;

    public RestrictedContentIndexConfig(
        IPublicAccessService publicAccessService,
        IScopeProvider scopeProvider
    )
    {
        _publicAccessService = publicAccessService;
        _scopeProvider = scopeProvider;
    }

    public IContentValueSetValidator GetContentValueSetValidator() =>
        new ContentValueSetValidator(false, true, _publicAccessService, _scopeProvider);

    public IContentValueSetValidator GetPublishedContentValueSetValidator() =>
        new ContentValueSetValidator(true, true, _publicAccessService, _scopeProvider);

    public IValueSetValidator GetMemberValueSetValidator() => new MemberValueSetValidator();
}
and register it in a composer:
Copy code
builder.Services.AddSingleton<IUmbracoIndexConfig, RestrictedContentIndexConfig>();
Then it will support restricted content.
n
The code looks correct, but make sure you are registering the options.
builder.Services.ConfigureOptions<ConfigureIndexOptions>();
I had some issues where my ordering was incorrect, so my code was hitting and then another package/tool was overriding my setup, so the order you add things will matter.
14 Views