SharePoint Search deletes HOSTS file and then throws HOSTS file not found error
Today I found this weird error message in my MOSS Server Event Logs. I just don’t understand why is SharePoint Search Admin Job is calling ‘System.IO.FileInfo.Delete()’ on hosts file.
Application Server Administration job failed for service instance Microsoft.Office.Server.Search.Administration.SearchServiceInstance (e9de7a85-9375-431c-b48b-b1ef522b6f65).
Reason: Access to the path ‘C:\WINDOWS\system32\drivers\etc\HOSTS’ is denied.
Techinal Support Details:
System.UnauthorizedAccessException: Access to the path ‘C:\WINDOWS\system32\drivers\etc\HOSTS’ is denied.
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.FileInfo.Delete()
at Microsoft.Search.Administration.Security.HOSTSFile.CleanupDedicatedGathering(Hashtable HOSTSFileMappings, StringBuilder HOSTSComments, IEnumerable obsoleteHosts, String dedicatedName, Boolean isDirty)
at Microsoft.Search.Administration.Security.HOSTSFile.ConfigureDedicatedGathering(SearchServiceInstance searchServiceInstance, SPServer dedicatedWebFrontEndServer, IList`1 previousWebApplicationHostNames)
at Microsoft.Office.Server.Search.Administration.SearchServiceInstance.SynchronizeDefaultContentSource(IDictionary applications)
at Microsoft.Office.Server.Search.Administration.SearchServiceInstance.Synchronize()
at Microsoft.Office.Server.Administration.ApplicationServerJob.ProvisionLocalSharedServiceInstances(Boolean isAdministrationServiceJob)For more information, see Help and Support Center at http://go.microsoft.com/fwlink/events.asp.
Out of curiosity I backed up hosts file and then gave ‘everyone’ full permissions to the hosts file then after some time I see this error message
Application Server Administration job failed for service instance Microsoft.Office.Server.Search.Administration.SearchServiceInstance (e9de7a85-9375-431c-b48b-b1ef522b6f65).
Reason: Could not find file ‘C:\WINDOWS\system32\drivers\etc\HOSTS’.
Techinal Support Details:
System.IO.FileNotFoundException: Could not find file ‘C:\WINDOWS\system32\drivers\etc\HOSTS’.
File name: ‘C:\WINDOWS\system32\drivers\etc\HOSTS’
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options)
at System.IO.StreamReader..ctor(String path, Encoding encoding, Boolean detectEncodingFromByteOrderMarks, Int32 bufferSize)
at System.IO.FileInfo.OpenText()
at Microsoft.Search.Administration.Security.HOSTSFile.ParseHOSTSFile(Hashtable& HOSTSFileMappings, StringBuilder& HOSTSComments)
at Microsoft.Search.Administration.Security.HOSTSFile.ConfigureDedicatedGathering(SearchServiceInstance searchServiceInstance, SPServer dedicatedWebFrontEndServer, IList`1 previousWebApplicationHostNames)
at Microsoft.Office.Server.Search.Administration.SearchServiceInstance.SynchronizeDefaultContentSource(IDictionary applications)
at Microsoft.Office.Server.Search.Administration.SearchServiceInstance.Synchronize()
at Microsoft.Office.Server.Administration.ApplicationServerJob.ProvisionLocalSharedServiceInstances(Boolean isAdministrationServiceJob)For more information, see Help and Support Center at http://go.microsoft.com/fwlink/events.asp.
Update : According to the Technet article you don’t have to add any specific permission om the MOSS server. But The account need to be able to add some entries to the host file for search purposes.
Apparently COMPUTER\WSS_ADMIN_WPG is suppose to have Modify permissions on the HOSTS-file, which fixes this problem. more info
Update 2 : I tried giving modify access to “WSS_ADMIN_WPG”, but it still didn’t solve the issue. My Hosts file is gone and am left with “Could not find file ‘C:\WINDOWS\system32\drivers\etc\HOSTS’.” errors in event log.

December 2, 2008 5:47 AM
try giving the SharePoint search users modify access as well.
This worked for me.
Post a Comment