开始在C#中使用的用户名和放大器的过程;密码抛出"访问被拒绝"例外 [英] Starting a process in C# with username & password throws "Access is Denied" exception
问题描述
在一个.NET 3.5的Web应用程序的运行冒充我试图通过执行过程:
Inside a .NET 3.5 web app running impersonation I am trying to execute a process via:
var process = new Process
{ StartInfo =
{ CreateNoWindow = true,
FileName = "someFileName",
Domain = "someDomain",
Username = "someUserName",
Password = securePassword,
UseShellExecute = false
}
};
process.Start();
- 改变信任模式充分在web.config中并没有解决。
-Changing the trust mode to full in web.config did not fix.
- 注意的VAR securePassword是一个SecureString的成立较早的code。
-Note the var securePassword is a secureString set up earlier in the code.
这将引发异常与访问被拒绝作为它的消息。如果删除了用户名和密码信息,异常消失,但是这个过程即开始的aspnet_wp,而不是我需要它的用户。
This throws an exception with 'Access is Denied' as its message. If I remove the username and password information, the exception goes away, but the process starts as aspnet_wp instead of the user I need it to.
我在多个论坛上看到了这个问题,从来没有见过提供的解决方案。 任何想法?
I've seen this issue in multiple forums and never seen a solution provided. Any ideas?
推荐答案
我去一个不同的方式,把整个应用程序在其自己的应用程序池的运行,我们最初是模拟用户。现在,当asp.net产生一个新的进程,它的用户,而不是的aspnet_wp的环境下滋生。不是这个问题的精确解我张贴,但它的工作为我们的情况。
I went a different way and put the whole application in its own app-pool running as the user we were originally impersonating. Now, when asp.net spawns a new process, it spawns under the context of the user instead of aspnet_wp. Not the exact solution to the problem I posted, but it worked for our situation.
这篇关于开始在C#中使用的用户名和放大器的过程;密码抛出"访问被拒绝"例外的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!