Monday, June 20, 2011

The dreaded Unspecified Error '80004005'. IIS7, OleDB and MS Access

Today it happened again. We were testing an ASP.NET website running under IIS 7 on W2K8 64bit. The website uses Windows authentication. The OleDB driver could connect happily to the MSAccess using the Microsoft.ACE.OLEDB.12 driver when using the browser from an account on the server, however connecting from a different client using Windows credentials failed with the dreaded Unspecified Error '80004005' OleDBException. This terrible unspecific error could mean anything.
After checking all kinds of settings and coding errors I decided to start a Coder's best friend, PROCMON (Process Monitor). I am always somewhat overwhelmed by the hundreds of thousands messages that show up. After filtering on process name (w3wp.exe) became obvious what was the problem. Just before the exception is thrown it shows ACCESS DENIED on directory c:\windows\ServiceProfiles\NetworkService\AppData\Local\Temp. Giving all users read/write access to this directory solved the problem.
I never saw this behaviour in IIS6. The reason is that in IIS6 the driver writes in c:\windows\temp and by default all users have write access on this directory. In IIS7 the temp directory for the NETWORK SERVICE account is no longer c:\windows\temp but c:\windows\ServiceProfiles\NetworkService\AppData\Local\Temp and only NETWORK SERVICE has access to this directory. When using windows authentication impersonation is used and an other user than NETWORK SERVICE tries to write in the directory and an exception is thrown.

No comments:

Post a Comment