【发布时间】:2010-10-09 19:58:44
【问题描述】:
我在 IIS 的应用程序中使用模拟。我需要将文件写入文件系统,但在这种情况下不想使用模拟用户的凭据。我需要使用应用程序池的凭据。
如何临时将工作进程的凭据从模拟凭据提升到应用程序池的凭据?
【问题讨论】:
标签: iis impersonation credentials
我在 IIS 的应用程序中使用模拟。我需要将文件写入文件系统,但在这种情况下不想使用模拟用户的凭据。我需要使用应用程序池的凭据。
如何临时将工作进程的凭据从模拟凭据提升到应用程序池的凭据?
【问题讨论】:
标签: iis impersonation credentials
经过多次谷歌搜索找到了答案。
using System.Security.Principal;
WindowsImpersonationContext ctx =
WindowsIdentity.Impersonate(System.IntPtr.Zero);
//do stuff in app pool's security context
ctx.Undo();
http://www.mindsharpblogs.com/todd/archive/2005/05/03/467.aspx
【讨论】: