【发布时间】:2011-02-08 10:51:32
【问题描述】:
代码:
System.Security.Principal.WindowsImpersonationContext impersonationContext;
impersonationContext =
((System.Security.Principal.WindowsIdentity)User.Identity).Impersonate();
//access network resources.
impersonationContext.Undo();
web.config:
<authentication mode="Windows">
</authentication>
<identity impersonate="true"
userName="user"
password="password"></identity>
从 web.config 文件中可以清楚地看出,该应用程序以模拟模式运行。我需要在此之上临时模拟以访问网络资源。如上所示,我这样做了。
如果我浏览到安装在服务器上的本地 IE 上的网站,这在服务器上可以正常工作,但是当我从我的 PC 或任何其他 PC 访问该应用程序时,我的访问被拒绝。
顺便说一句,这一切都在企业域环境中。所以 IE 在这两种情况下都传递了一个有效的认证令牌。
任何想法发生了什么。谢谢。
【问题讨论】:
标签: asp.net iis impersonation