Security Trimmers on SharePoint 2010
-
16-10-2019 - |
Pergunta
SharePoint 2010 changed a lot of things about security trimming from 2007. I've implemented the new ISecurityTrimmer2 interface, and I've registered my trimmer with SharePoint (following the suggestions here). However, my trimmer is not consulted during a search. There are messages in the logs about security trimming, like "PluggableSecurityTrimmerManager:SetSearchApplicationToUse: Set SearchApplication to 'Search Service Application'". Any ideas what I'm doing wrong? Is there a necessary step in addition to registering the trimmer? If it matters, I'm using BDC to allow SharePoint to crawl my content, and this part is successful.
Most of the documentation on the web deals with registering security trimmers using PowerShell. For ease of deployment, I'm registering from C# code running during installation. One difference in the approaches which may explain the behaviors is that the PowerShell command takes a crawl rule, while the PluggableSecurityTrimmerManager does not.
Solução
using code you can do the same thing but you will have to manipulate multiple objects
PluggableSecurityTrimmerManager as you know
and then CrawlRule
using this CrawlRule object, you can do things like
SearchAdmin.CrawlRule crawlRule = content.CrawlRules.Create(SearchAdmin.CrawlRuleType.InclusionRule, "yourRulePath");
crawlRule.PluggableSecurityTrimmerId = securityTrimmerId;
crawlRule.Update();
the securityTrimmerId refers to the id of your custom SecurityTrimmer
Hope it helps!
Outras dicas
have you followed the original msdn documentation :
http://msdn.microsoft.com/en-us/library/ee819923.aspx
every steps is listed there; you cannot get it wrong!
edit: there is indeed a comamand you should execute to register the trimmer
New-SPEnterpriseSearchSecurityTrimmer -SearchApplication "Search Service Application" -typeName "CustomSecurityTrimmerSample.CustomSecurityTrimmer, CustomSecurityTrimmerSample, Version=1.0.0.0, Culture=neutral, PublicKeyToken=token" -RulePath file://FileServer1/* -id 1
check the link
gl
It is mandatory to register your trimmer with the Search Service Application. For that ,make sure you use PluggableSecurityTrimmerManager.SetSearchApplicationToUse method and provide correct Search Service Application name configured in your farm.Below is the code to do that:
SPFarm farm = SPFarm.Local; SearchService searchService = farm.Services.GetValue(); SearchServiceApplication searchServApp = searchService.SearchApplications.GetValue([SearchApplicationName])();
PluggableSecurityTrimmerManager trimmerManager = PluggableSecurityTrimmerManager.Instance; trimmerManager.SetSearchApplicationToUse(searchServApp); trimmerManager.RegisterPluggableSecurityTrimmer(id, assemblyQualifiedName, new NameValueCollection());