Search results page gives "Internal server error exception"

​Let's say you have SharePoint Server installed on a single machine, perhaps for development purposes. Unless you are a member of a domain you will be using local accounts. You need to provision search. Everything looks fine - the search service application provisions okay. You can create a Basic Search Center or Enterprise Search Center site. Everything seems to be working fine until you go to the search results page and you get the "Internal server error exception" message along with the usual correlation ID.

If you go to your search service application management page you will probably see, at the bottom of the screen, that the Query Service is stuck in the "initializing" state. Without a working query server the search results web part is not able to render and will throw the exception that results in the error message. You will get this problem if you set up search using the SharePoint UI in Central Administration, and also if you use the supplied PowerShell cmdlets.

So why doesn't the query service get configured correctly? The fundamental problem seems to be the security descriptor used to set up the file shares that the search service uses to store and propagate the indexes. You may see an error "Topology activation was aborted because of System.ArgumentException: The SDDL string contains an invalid sid or a sid that cannot be translated". The out-of-the-box provisioning components do not seem to know how to consrtuct a valid SID when using local security accounts.

The solution is to use the SharePoint Object Model at a lower level to build the search service application. Gary Lapointe has written a PowerShell script that can provision search in this way. It is a bit more effort to use, and it is certainly one of the more complex provisioning scripts. You will need to scan through the comments against this post for a few modifications to support local accounts. There is also an excellent post by Søren Nielsen who has a ready-to-go script for local account use, as well as a sample configuration file. This will work on Windows Server with local accounts and also on Windows 7 if you are using the client SharePoint install as a development environment. It should also work with SharePoint Foundation and Search Server Express if you are going for a low-cost SharePoint server solution, although I have not yet tested this.