FIM ScriptBox Item
Summary
With the release of Forefront Identity Manager R2 2010, the Search Scopes have had some improvements to their overall performance. This was achieved by changing the search scope of DisplayName to use start-with rather than contains. That is, in FIM 2010 for example if we were to do a search in the FIM Portal for all users named John then the query used to look like this:
/Person [(contains(DisplayName, 'john') or starts-with(AccountName, 'john') or starts-with(MailNickname, 'john'))]
In FIM 2010 R2 the query would look like this:
/Person [(starts-with(DisplayName, 'john') or starts-with(AccountName, 'john') or starts-with(MailNickname, 'john'))]
The reason for this is that in large databases, the contains query performs poorly with prefix-term searches. A prefix term refers to a string that is affixed to the front of a word to produce a derivative word or an inflected form. For a single prefix term, any word starting with the specified term will be part of the result set. For example, the term "auto*" matches "automatic", "automobile", and so forth. This change affects anything that uses or builds a Search Scope.
Because some organizations may want to continue to use the contains operator, two new attributes have been introduced to allow the contains functionality to continue. They are:
AdvancedFilter
The AdvancedFilter box is available on the Extended Attributes of a Search Scope. You cannot specify the AdvancedFilter when creating a new Search Scope only after it has been created in the FIM Portal and you have access to the Extended Attributes. If you want to revert all of your search scopes back to the original, FIM 2010 version you can use the following PowerShell script to accomplish this. This script checks each SearchScope within FIM to see if the DisplayName is in the list of Attributes to Search and the AdvancedFilter is not already set. If so, this will update the AdvancedFilter property to hold the necessary x-path which reverts to the "Contains" search instead of starts-with for the DisplayName attribute. If you want to wipe out changes caused by this script, you can use this companion script.
Script Code
Note that this will affect the Search Scope objects used for search boxes while your Object Pickers will not be affected (i.e. not reverted to FIM 2010 functionality). If you want to revert the search functionality for Object Pickers then you must manually configure each Object Picker to employ the new DefaultSearchScopeName property. This will involve creating a new Search Scope for that Object Picker and migrating the search-scope-like properties from the Object Picker to its new Search Scope. After migrating all the Object Pickers to employ the new DefaultSearchScopeName property you can run this script to configure those new Search Scopes to employ "contains" instead of starts-with.