How to impersonate a user from Active Server Pages (248187)
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 Q248187 SUMMARY
This article describes impersonation and the security context for Active Server Pages (ASP) pages. It provides sample code for a Microsoft Visual Basic ActiveX dynamic-link library (DLL) that can be instantiated from an ASP page to impersonate a user and change the security context of the current thread.
By default, ASP runs in the security context of the impersonated user. When a request for an ASP file is made, the Web server utilizes a worker thread and sets the security context of that thread to an impersonated user. The Internet Information Server (IIS) authentication method (Anonymous, Basic, NT Integrated, and so on) determines the impersonated user. Then, the ASP code runs in the context of that user.
When you impersonate a user, you can resolve the following security conflicts in your application:
- An application that uses NT Integrated (NTLM) security or Kerberos to authenticate that needs to access a network resource (such as a file, an Access database, or a SQL Server) through the Named Pipes protocol.
- An application that accesses a network resource from the Session_OnEnd or Application_OnEnd event.
The Session_OnEnd and Application_OnEnd events run with the identity of the process. For in-process or Low application protection applications, this is the SYSTEM user ID, and the process is the Inetinfo.exe file. Rather than impersonating, you can run in a separate memory process or with High (isolated) application protection and set the identity of the Microsoft Transaction Server (MTS) package or COM+ application to the desired user ID. - An application that supports multiple users who are connecting to the WinNT:// namespace through Microsoft Active Directory Services Interface (ADSI).
These connections are cached with the security credentials of the first user that opens the connection. Impersonating ensures that a single user opens the connection; as a result, that user's credentials match the cached credentials.
Modification Type: | Minor | Last Reviewed: | 7/8/2005 |
---|
Keywords: | kbhowto kbSecurity KB248187 |
---|
|