我在ASP.NET 2.0中的模拟上下文中启动进程时遇到问题。进程启动和假冒
我开始在我的web服务代码中的新进程。 IIS 5.1,.NET 2.0
[WebMethod]
public string HelloWorld()
{
string path = @"C:\KB\GetWindowUser.exe";
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.WorkingDirectory = Path.GetDirectoryName(path);
startInfo.FileName = path;
startInfo.UseShellExecute = false;
startInfo.CreateNoWindow = true;
startInfo.ErrorDialog = false;
startInfo.RedirectStandardOutput = true;
startInfo.RedirectStandardError = true;
Process docCreateProcess = Process.Start(startInfo);
string errors = docCreateProcess.StandardError.ReadToEnd();
string output = docCreateProcess.StandardOutput.ReadToEnd();
}
的 “C:\ KB \ GetWindowUser.exe” 是一个包含以下代码的控制台应用程序:
static void Main(string[] args)
{
Console.WriteLine("Windows: " + WindowsIdentity.GetCurrent().Name);
}
当我调用Web服务而不模仿,一切工作正常。
当我打开模拟,下面的错误是用“错误”在Web服务代码变量:
未处理的异常信息:System.Security.SecurityException:访问被拒绝\ r \ n \ r \ n在System.Security.Principal.WindowsIdentity.GetCurrentInternal(TokenAccessLevels desiredAccess,Boolean threadOnly)\ r \ n在System.Security.Principal.WindowsIdentity.GetCurrent()\ r \ n在ObfuscatedMdc.Program.Main(String [] args)\ r \ n \ r \ n失败的程序集的区域是:\ r \ nMyComputer
模拟用户是本地管理员并且可以访问C:\ KB \ GetWindowUser.exe可执行文件。
当我明确指定窗口用户ProcesStartInfo属性域,用户和密码,我得到了以下信息: http://img201.imageshack.us/img201/5870/pstartah8.jpg
是否有可能从asp.net不同的凭据比ASPNET(IIS 5.1)启动过程?
提到了完整的源代码示例工作任何关于它的最终解决方案包内
你的代码? – Kiquenet 2013-07-05 06:34:55