请考虑以下场景:
我有一个网站,托管在IIS 7.0背后。几乎所有的IIS设置都是默认设置。我有一个上传文件的文件夹,ASP.Net用户对it.currently有写权限,IIS管理器取消这个写权限,他想在Windows Server中添加一个本地用户,这个用户可以对该文件夹有写权限。现在我的问题是如何在asp.net中模拟用户,这种方法是否安全?我希望所有的请求执行在服务器上根据默认的IIS用户,但我只想模拟上传一个文件。
谢谢
发布于 2012-07-26 16:57:12
您需要的是部分模拟。你不需要模拟所有的请求,但只需要模拟几个调用。我想你一定要看看这篇文章。
http://support.microsoft.com/kb/306158
这就是它如何在登录用户的凭据下模拟一段代码,而其余调用将使用默认应用程序池标识进行处理
System.Security.Principal.WindowsImpersonationContext impersonationContext;
impersonationContext =
((System.Security.Principal.WindowsIdentity)User.Identity).Impersonate();
//Insert your code that runs under the security context of the authenticating user here.
impersonationContext.Undo();https://stackoverflow.com/questions/11664710
复制相似问题