<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Jie Li's GeekWorld : Security Trimming</title><link>http://blogs.msdn.com/opal/archive/tags/Security+Trimming/default.aspx</link><description>Tags: Security Trimming</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>SharePoint Search - Lotus Notes Indexing Best Practice</title><link>http://blogs.msdn.com/opal/archive/2008/07/01/sharepoint-search-lotus-notes-indexing-best-practice.aspx</link><pubDate>Tue, 01 Jul 2008 08:35:40 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8675325</guid><dc:creator>Jie Li</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/opal/comments/8675325.aspx</comments><wfw:commentRss>http://blogs.msdn.com/opal/commentrss.aspx?PostID=8675325</wfw:commentRss><description>&lt;p&gt;Many people have been asking for the best practice or a guide to properly maintain Lotus Notes indexing function in SharePoint Search. So here it is, this is not a official guide, but our experience in several big customers. I will write this in a Q/A format, so you can navigate to see which question applies to your current problem.&lt;/p&gt;  &lt;p&gt;Q1. How many Lotus Notes content source &lt;strong&gt;can&lt;/strong&gt; I crawl at the same time?     &lt;br /&gt;A1: One content source per Domino Server. If all of your stuff are put on a single Domino Server, you have to crawl them one by one. But If you have several Domino servers to index, then you can index them at the same time. This is a limitation of IBM Lotus Notes C++ API. So you may need to carefully set schedules to crawl these content sources.&lt;/p&gt;  &lt;p&gt;Q2. How many Lotus Notes content source &lt;strong&gt;shall&lt;/strong&gt; I crawl at the same time?     &lt;br /&gt;A2: The only difference from the 1st question is CAN/SHALL. There should be a limit on this number,&amp;#160; but what is this number? I don’t have the direct answer for the question, because this number depends on your hardware performance, memory usage, network legacy and bandwidth…. so many factors. For a recent hardware with 8GB ram, I would recommend 3,with scheduled memory recycling – we will talk about this later.&lt;/p&gt;  &lt;p&gt;Q3. I have a Notes database indexed, but how come the time of full crawl is nearly the same with incremental crawl?    &lt;br /&gt;A3: During an incremental crawl, SharePoint search engine will check LastModifiedTime property of target documents/items, and to determine if the target object should be fully retrieved back to its index. However, for certain content source, this property is not retrieved or mapped to something else by mistake, therefore, the engine can only get all the content back to check if there’s any difference. I’m checking a possible solution for this problem, and will update if I can find something.&lt;/p&gt;  &lt;p&gt;Q4. Should I use x86 or x64 for Lotus Notes indexing?    &lt;br /&gt;A4: Because of the limitation of IBM Notes C++ API, Notes Protocol Handler can only run on a x86 box. However, you can still use x64 query servers and WFEs. Remember: the same tier should not be mixed with x64/x86 boxes, but you can have x86 indexer tier with x64 query and x64 wfe tiers, this is recommended for Notes search in SharePoint 2007/Search Server 2008. (IBM released x64 version of their API recently, but it’s impossible to make current NotesPH to work with that, many things changed)&lt;/p&gt;  &lt;p&gt;Q5. You mentioned memory recycling – what does that mean?    &lt;br /&gt;A5: Due to x86 limitation, the memory per process is limited to certain number. And because we are calling Notes client through API, it’s quite possible MSSEARCH/MSSDMN process will hit memory limit after a crawl of large numbers of documents. So I recommend you to recycle these processes for every certain amount of time. This can prevent possible stuck of the crawl. In order to do this, you might need to write your own schedule program with SharePoint search administration APIs, and restart osearch service when it’s need. I will also add this function to SharePoint Search Admin 0.81 and later in a few days.&lt;/p&gt;  &lt;p&gt;Q6. Any ideas about security trimming support? What should I do in Domino side?    &lt;br /&gt;A6: You can use Lotus Notes users and groups to control security, and map them to AD users to achieve search result security trimming in SharePoint. But it is generally advised to not use Lotus Notes Roles for security control, as there’s no correspond thing in active directory.&lt;/p&gt;  &lt;p&gt;Q7. To be added.    &lt;br /&gt;A7:&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;Btw, I’m moving to a new position in IW PMG, as a Technical Product Manager to drive SharePoint IT Pro readiness. So in future there would be more things like SharePoint Governance appear on this blog:). &lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8675325" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/opal/archive/tags/Enterprise+Search/default.aspx">Enterprise Search</category><category domain="http://blogs.msdn.com/opal/archive/tags/Security+Trimming/default.aspx">Security Trimming</category><category domain="http://blogs.msdn.com/opal/archive/tags/SharePoint+Search+Admin/default.aspx">SharePoint Search Admin</category><category domain="http://blogs.msdn.com/opal/archive/tags/Domino/default.aspx">Domino</category><category domain="http://blogs.msdn.com/opal/archive/tags/Lotus+Notes/default.aspx">Lotus Notes</category></item><item><title>When, why and how to deal with Custom Security Trimmer in Enterprise Search? - Part II</title><link>http://blogs.msdn.com/opal/archive/2007/11/07/when-why-and-how-to-deal-with-custom-security-trimmer-in-enterprise-search-part-ii.aspx</link><pubDate>Wed, 07 Nov 2007 17:23:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:5959937</guid><dc:creator>Jie Li</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/opal/comments/5959937.aspx</comments><wfw:commentRss>http://blogs.msdn.com/opal/commentrss.aspx?PostID=5959937</wfw:commentRss><description>&lt;P&gt;In part II we will go through the code a little deeper. &lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Check permission against different systems&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;Please open this page,&lt;/P&gt;
&lt;P&gt;&lt;A title=http://msdn2.microsoft.com/en-us/library/aa981173.aspx href="http://msdn2.microsoft.com/en-us/library/aa981173.aspx" mce_href="http://msdn2.microsoft.com/en-us/library/aa981173.aspx"&gt;http://msdn2.microsoft.com/en-us/library/aa981173.aspx&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Look at this part of the code.&lt;/P&gt;&lt;PRE&gt;for (int x = 0; x &amp;lt; crawlURLs.Count; x++)
{
&lt;FONT color=#008040&gt;/*
To fully implement the security trimmer, add code to perform the security check and determine if strUser can access crawlURLs[x]. 
If strUser can access crawlURL[x], then:
*/&lt;/FONT&gt;
retArray[x] = true;
&lt;FONT color=#008040&gt;//If not:&lt;/FONT&gt;
retArray[x] = false;
}
&lt;/PRE&gt;
&lt;P&gt;Quite simple explanation. But how can you ? &lt;/P&gt;
&lt;P&gt;1. Use WindowsIdentity.GetCurrent().Name to get current username, or if you are using FBA, that is HttpContext.Current.User.Identity.Name. &lt;/P&gt;
&lt;P&gt;2. Then use this username to check with the target system, if he has the permission to crawlURL[x], then return a True.&lt;/P&gt;
&lt;P&gt;Different system has different security checking method. Here' re some suggested ways to check security:&lt;/P&gt;
&lt;TABLE class="" cellSpacing=0 cellPadding=2 width=480 border=0&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD class="" vAlign=top width=210&gt;&lt;STRONG&gt;Content source&lt;/STRONG&gt;&lt;/TD&gt;
&lt;TD class="" vAlign=top width=268&gt;&lt;STRONG&gt;Method&lt;/STRONG&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="" vAlign=top width=210&gt;Web Sites, with SQL Server in backend&lt;/TD&gt;
&lt;TD class="" vAlign=top width=268&gt;Directly use System.Data.Sqlclient to deal with the database and get the permission&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="" vAlign=top width=210&gt;Web Sites, with Oracle in backend&lt;/TD&gt;
&lt;TD class="" vAlign=top width=268&gt;System.Data.OracleClient. You must install Oracle Client first.&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="" vAlign=top width=210&gt;Web Sites, with DB2 in backend&lt;/TD&gt;
&lt;TD class="" vAlign=top width=268&gt;DB2 .Net Data Provider&lt;BR&gt;ODBC&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="" vAlign=top width=210&gt;Web Sites, with MySQL in backend&lt;/TD&gt;
&lt;TD class="" vAlign=top width=268&gt;MySQLDriverCS&lt;BR&gt;&lt;A title=http://sourceforge.net/projects/mysqldrivercs/ href="http://sourceforge.net/projects/mysqldrivercs/" mce_href="http://sourceforge.net/projects/mysqldrivercs/"&gt;http://sourceforge.net/projects/mysqldrivercs/&lt;/A&gt;&lt;BR&gt;or MySQL connector/NET&lt;BR&gt;&lt;A title=http://www.mysql.com/products/connector/net/ href="http://www.mysql.com/products/connector/net/" mce_href="http://www.mysql.com/products/connector/net/"&gt;http://www.mysql.com/products/connector/net/&lt;/A&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="" vAlign=top width=210&gt;File Share&lt;/TD&gt;
&lt;TD class="" vAlign=top width=268&gt;File.GetAccessControl&lt;BR&gt;SharePoint already has security trimming function built-in for file shares. It would be very uncommon that you need to deal with CST in this scenario.&lt;BR&gt;&lt;FONT color=#ff0000&gt;But be aware, if you want extra security trimming with file shares, the built-in security trimmer(the one applied in query time we talked in part I) will applied first. There's no way to get it replaced. And if you are using FBA, which means your current identity is changed from windows user to a httpcontext user, you will get nothing in your search result if the file share is not a public one. &lt;/FONT&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="" vAlign=top width=210&gt;Lotus Notes&lt;/TD&gt;
&lt;TD class="" vAlign=top width=268&gt;Lotus Domino Objects, a COM object to be used in other languages&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;
&lt;P&gt;&lt;STRONG&gt;If you want to have a better performance when a CST is applied...&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;I suggest that you cache the permission settings to your own box and check it in CST. Remote calls may have huge impact on the performance, especially Lotus Notes. Meanwhile, check security with remote machine also means an impact to the target system. If that system is critical, this will affect customer's business.&lt;/P&gt;
&lt;P&gt;The cache thing can be done with some small tools, of course you can write a small application by using Lotus Domino Objects and grab all the notes ACL back to a SQL table, that depends on your own opinion.&lt;/P&gt;
&lt;P&gt;Another important thing is to set a CheckLimit in your CST. If CheckLimit is reached, CST will report something back to user, or do something you defined, and stop the check. This message can be something like "too many results pls refine your keywords", "Please try keyword1+keyword2+keyword3"....That will help.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Register a custom security trimmer&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;The trimmer must be compiled with strong name. You must first install it to the assembly by the following command(There're some errors in SDK): &lt;/P&gt;
&lt;P&gt;&lt;FONT color=#004080&gt;C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\Bin&amp;gt;gacutil.exe /i c:\Trimmer\CustomSecurityTrimmerSample.dll /f&lt;/FONT&gt; 
&lt;P&gt;C:\Trimmer\CustomSecurityTrimmerSample.dll is my trimmer's path, change it with your own one.&amp;nbsp; 
&lt;P&gt;A very important step: Create an "include" crawl rule with the URL you want to bind this CST with. If you don't create it, you cannot deploy the trimmer. In this sample, the path is &lt;STRONG&gt;http://localhost:8100/*&lt;/STRONG&gt;. 
&lt;P&gt;Then you should deploy it with stsadm: 
&lt;P&gt;&lt;FONT color=#004080&gt;C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\BIN&amp;gt;stsadm -o registersecuritytrimmer -ssp SharedServices1 -id 2 -typeName "CustomSecurityTrimmerSample.CustomSecurityTrimmer, CustomSecurityTrimmerSample, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b6c7fa67516b1230" -rulepath &lt;/FONT&gt;&lt;A href="http://localhos/" mce_href="http://localhos"&gt;&lt;FONT color=#004080&gt;http://localhos&lt;/FONT&gt;&lt;/A&gt;&lt;FONT color=#004080&gt;t:8100/* &lt;/FONT&gt;
&lt;P&gt;PublicKeyToken is the token you can see in windows\assembly directory. rulepath is the crawl rule path you just created. 
&lt;P&gt;And don't forget iisrset. Then, if any search result matches the crawl rule, CST will be launched to check the permission.&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=5959937" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/opal/archive/tags/Enterprise+Search/default.aspx">Enterprise Search</category><category domain="http://blogs.msdn.com/opal/archive/tags/Security+Trimming/default.aspx">Security Trimming</category></item><item><title>When, why and how to deal with Custom Security Trimmer in Enterprise Search? - Part I</title><link>http://blogs.msdn.com/opal/archive/2007/11/05/when-why-and-how-to-deal-with-custom-security-trimmer-in-enterprise-search-part-i.aspx</link><pubDate>Mon, 05 Nov 2007 11:37:08 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:5903133</guid><dc:creator>Jie Li</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/opal/comments/5903133.aspx</comments><wfw:commentRss>http://blogs.msdn.com/opal/commentrss.aspx?PostID=5903133</wfw:commentRss><description>&lt;p&gt;First of all, security trimming is very important in Enterprise Search. Users who have no rights to the documents should not see descriptions in their search results. They should not be aware of those items at all. &lt;/p&gt; &lt;p&gt;When building Enterprise Search solutions using Microsoft SharePoint Server 2007(MOSS), you can find that MOSS support file share, sharepoint, lotus notes security trimming out of the box. This means, the protocol handler picks up ACL in index time, and security trimming will be applied at query time. Such query behavior is like a SQL sentence: &lt;/p&gt; &lt;p&gt;SELECT * from scope() where freetext("keyword") and YourCurrentUserRight="True"&amp;nbsp; (This is not the real sql sentence, just to give you an idea)&lt;/p&gt; &lt;p&gt;So query performance will not be impacted. &lt;/p&gt; &lt;p&gt;But, what about other stuff like website, database, or a custom content source?&lt;/p&gt; &lt;p&gt;Custom Security Trimmer(CST) is used in MOSS, to support security trimming of such things. The behavior of CST is quite different from build-in security trimmer. It is run at query time, but because the YourCurrentUserRight value is not there, CST will access target system to retrieve this value after the search results come out. It will check one by one, for example, there're 4,000 items in the result about "jokes", but you can only access 100 items. So the process changed to:&lt;/p&gt; &lt;p&gt;1. Do a search for "jokes", this is like SELECT * from scope() where freetext("keyword"), and no security trimming applied. 4,000 items returned in the result. This is not displayed to the user.&lt;/p&gt; &lt;p&gt;2. Because CST is registered with "crawl rules"(this is one of the worst name examples I had ever seen in Microsoft, wth, a rule applied at query time is called CRAWL RULE?), if the path of the item meet the rule, CST will be launched to check if current user has the permission to read this item. If he has, CST will report a "True". Note, multiple CST instances will be launched at the same time to check different items, and it seems you cannot control this number. I think it's around 4-5.&lt;/p&gt; &lt;p&gt;3. After the "True" number of items in one page is meet, for example 10 items CST reported True after checked against about 200 items, the first page of result will be displayed. &lt;/p&gt; &lt;p&gt;Let's do some basic calculation job. What will happen if a bad CST is applied? The key point is how much time will be used to check the permission in CST. If a CST will need one second to check one item, meanwhile 4 CSTs are launched, 200 items will need you 50 seconds to complete the job. This means, you have to wait for 50 seconds to get the search result showed in your browser!&lt;/p&gt; &lt;p&gt;Terrible, right? Even worse, if you have 100,000 items in a result array, and you only have permission against 4 items, the search service will crush because of the timeout.&lt;/p&gt; &lt;p&gt;So that's why CheckLimit is also needed in the implementation of CST. &lt;/p&gt; &lt;p&gt;Now, the best practice when you want to create a CST:&lt;/p&gt; &lt;p&gt;1. Reduce the time needed to check the permission. You can do some trick to make it faster, for example, store the permission mapping in a local SQL table first, and use CST to check local table not the remote one, so you can bypass the network delay. &lt;/p&gt; &lt;p&gt;2. Correctly set CheckLimit. Return a more user friendly message when the limit is met.&lt;/p&gt; &lt;p&gt;To implement a CST, you can refer to SDK, or these articles:&lt;/p&gt; &lt;p&gt;&lt;a title="http://msdn2.microsoft.com/en-us/library/aa981236.aspx" href="http://msdn2.microsoft.com/en-us/library/aa981236.aspx"&gt;http://msdn2.microsoft.com/en-us/library/aa981236.aspx&lt;/a&gt;&lt;br&gt;&lt;a title="http://msdn2.microsoft.com/en-us/library/aa981563.aspx" href="http://msdn2.microsoft.com/en-us/library/aa981563.aspx"&gt;http://msdn2.microsoft.com/en-us/library/aa981563.aspx&lt;/a&gt;&lt;/p&gt; &lt;p&gt;These are not very good articles, some of the information are misleading. So far as I know, there're some much better articles on the way, but I don't know the exact date of when they will be published on MSDN.&amp;nbsp; Later in another post I will go through the code to explain more.&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=5903133" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/opal/archive/tags/Enterprise+Search/default.aspx">Enterprise Search</category><category domain="http://blogs.msdn.com/opal/archive/tags/Security+Trimming/default.aspx">Security Trimming</category></item></channel></rss>