Cannot access network resources in Application_OnEnd or Session_OnEnd Events (277329)
The information in this article applies to:
- Microsoft Active Server Pages
- Microsoft Internet Information Server 4.0
- Microsoft Internet Information Server 5.0
This article was previously published under Q277329 SYMPTOMS
When you try to access a network resource from the Application_OnEnd or Session_OnEnd event, the action may fail, and the event is terminated. In addition, you may receive an error in the Application Log of the Event Viewer or in the browser window itself. This error refers to a line of code in the Global.asa file.
For example, when you use the Scripting.FileSystemObject method to open a file, you may receive the following error message:
Microsoft VBScript runtime (0x800A0046)
Permission denied
When you connect to an Access database, you may receive the following error message:
Microsoft OLE DB Provider for ODBC Drivers (0x80004005)
[Microsoft][ODBC Microsoft Access Driver] The Microsoft Jet database engine cannot open the file '(unknown)'. It is already opened exclusively by another user, or you need permission to view its data.
When you connect to a SQL Server database, you may receive the following error message:
Microsoft OLE DB Provider for ODBC Drivers (0x80040E4D)
[Microsoft][ODBC SQL Server Driver][SQL Server]Login failed for user 'NT AUTHORITY\ANONYMOUS LOGON'.
CAUSE
The Application_OnEnd and Session_OnEnd events do not run with the security context of the impersonated user, that is, the user that is determined by the Internet Information Server (IIS) authentication method (Anonymous, Basic, NT Integrated, and so on). Instead, these events run in the security context of the process itself.
For in-process or Low application protection applications, SYSTEM is the identity of the IIS service. Because the SYSTEM user ID is restricted to local computer access, access to network resources fails.
For isolated processes, Medium pooled, or High isolated applications, this is the identity of the Microsoft Transaction Server (MTS) or COM+ package. By default, this identity is IWAM_<computername>, which is an account that exists in the local NT user database. If the Web server is not running on a Domain controller (which it is usually not), this user ID cannot access resources other than those that are local to the Web server.
RESOLUTION
There are two ways to resolve this problem:
- Set the ASP application to run as an MTS or COM+ package that is run in separate memory space for IIS 4.0 or to High (isolated) for IIS 5.0. Then, set the identity of that package to a user ID that can access the network resource. This changes the process from the IIS process (inetinfo.exe) to either Mtx.exe (IIS 4.0) or Dllhost.exe (IIS 5.0) and changes the security context of the process to the MTS or COM+ identity.
For information on how to set up an ASP application as an MTS or COM+ package, see the "More Information" section.
- To change the security context, call the impersonation APIs.
For more information, click the following article number to view the article in the Microsoft Knowledge Base:
248187
How to impersonate a user from Active Server Pages
REFERENCES
For more information, click the following article number to view the article in the Microsoft Knowledge Base:
248187
How to impersonate a user from Active Server Pages
Modification Type: | Major | Last Reviewed: | 6/27/2006 |
---|
Keywords: | kbprb kbSecurity KB277329 |
---|
|