如何使用特定的用户名和密码启动IIS进程

Pri*_*kar 5 c# asp.net iis system.diagnostics process

我正在尝试从我们的内部网站运行应用程序.当我使用时,Process.Start("notepad");我可以看到记事本进程在我们的Web服务器中启动,并在应用程序池设置中提到了默认标识.

但我必须使用特定的用户名和密码启动该过程.所以我试着运行这行代码

string password = "XXXXX";
System.Security.SecureString securePwd = new System.Security.SecureString();
foreach (char c in password)
{
    // Append the character to the password.
    securePwd.AppendChar(c);
}
Process.Start("notepad", "username", securePwd, "domain");
Run Code Online (Sandbox Code Playgroud)

在这种情况下,我甚至没有看到在Web服务器中启动任何记事本进程.执行的代码行,因为当我输入错误的密码时,我可以看到我的网页抛出"错误的用户名或密码"错误.

Pri*_*kar 4

谢谢大家的回复。在这里我得到了解决方案,现在我的过程从模拟用户开始。

https://learn.microsoft.com/en-US/troubleshoot/aspnet/spawn-process-under-impersonated-user

谢谢。