我在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