BUG: Named pipes do not work when worker process runs under ASPNET account


You may receive an error message if all the following conditions are true:
  • An ASP.NET worker process (Aspnet_wp.exe) runs under the default ASPNET account.
  • You do not enable impersonation on that application.
  • You use the SQL Server .NET Data Provider or the OLE DB .NET Data Provider to connect to a database.
You may receive any of the following error messages:

Message 1
OleDbException (0x80004005): [DBNETLIB][ConnectionOpen (Connect()).]SQL Server does not exist or access denied.]
Message 2
SqlException (0x80004005): [DBNETLIB][ConnectionOpen (Connect()).]SQL Server does not exist or access denied.]
Message 3
System.Data.SqlClient.SqlException: SQL Server does not exist or access denied
Message 4
System.Data.OleDbClient.OleDbException: SQL Server does not exist or access denied


When the ASP.NET worker process runs under the ASPNET account, if you do not enable impersonation for an application, all the threads that run the requests for that application run under the process account. The ASPNET account cannot establish a named pipes connection to the database server.


To work around this problem, use one of the following methods:
  • Turn on impersonation on your ASP.NET application. This method works if the impersonated user has access to the computer and to the database server that you access.
  • Use Transmission Control Protocol/Internet Protocol (TCP/IP) instead of the named pipes protocol to connect to the database. To do this, add the following attribute to the connection string:
    "Network Library =dbmssocn"
    For example:
    "User ID=myUserId;Password=myPassword;Initial Catalog=Pubs;Data Source=myServer;Network Library =dbmssocn"
  • Check the database for the protocols that are enabled. For a SQL Server database, run the Server Network Utility to check for specific protocols.


Microsoft has confirmed that this is a bug in the Microsoft products that are listed in the "Applies to" section.


For additional information about ASP.NET security, click the following article number to view the article in the Microsoft Knowledge Base:

306590 ASP.NET security overview

For more information about the <processModel> section, refer to the following MSDN documentation:

ID articolo: 315159 - Ultima revisione: 21 mag 2009 - Revisione: 1