简体   繁体   English

asp.net中的模拟不与com对象共享

[英]Impersonation in asp.net not shared with com object

So I have an ASP DOT NET web service which needs to impersonate Windows Authenticated users. 因此,我有一个ASP DOT NET Web服务,该服务需要模拟Windows Authenticated用户。 This web service calls into a Com Api to perform database operations. 该Web服务调用Com Api来执行数据库操作。

It seems like the Impersonation does not persist into the Com Api. 模仿似乎并没有持续存在于Com Api中。 Is this because the Com DLL is loaded into its own memory space and treated as a separate process? 这是因为Com DLL被加载到其自己的内存空间中并被视为一个单独的进程吗? Also what would be some ways to deal with this issue and persist the Impersonation into the Com Api Dll? 还有什么方法可以解决此问题,并将模拟继续保存到Com Api Dll?

Moving the functionality of the Com Api into the dot net code is not an option at this point. 此时,不能将Com Api的功能移入点网代码。 Also the Com Api was written in C++. Com Api也是用C ++编写的。

So I fixed the problem. 所以我解决了这个问题。 The Com Object is loaded into its own thread and Impersonation being set the way I did is Thread level. Com对象被加载到其自己的线程中,而模仿方式的设置是线程级别。 Since I have control of the Com Object adding the Windows function CoImpersonateClient(); 由于我控制了Com对象,因此添加了Windows函数CoImpersonateClient();。 before any code that needed to be impersonated did the trick. 在需要模拟的任何代码之前,都可以做到这一点。

Here is the article I finally found that resolved the problem: 这是我终于找到解决问题的文章:

http://support.microsoft.com/default.aspx?scid=kb;en-us;Q325791 http://support.microsoft.com/default.aspx?scid=kb;zh-CN;Q325791

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM