我试图从我的Asp.Net Web应用程序执行PSExec
以连接到远程服务器。不知何故,它给"Access Denied Error -5"
没有设置凭据,并通过在PSEXEC命令中设置凭据"2250 Network connection could not be found"
。我是服务器上的管理员,我启用了Windows authentication and Asp.Net Impersonation
(IIS7.5
)。更有趣的是,当我尝试从console application
或甚至仅使用command prompt
执行此操作时,它只是正常工作。我正在尝试做一个ping操作作为测试。从Asp.Net Web应用程序使用sysinternals PSExec执行脚本
这里是我的代码片段: -
var startInfo = new ProcessStartInfo{
CreateNoWindow = true,
UseShellExecute = false,
FileName = FilePath,
Arguments = CommandArgs
}
Process vsCommandProcess = Process.Start(startInfo);
vsCommandProcess.WaitForExit();
var exitCode = vsCommandProcess.ExitCode;
if (vsCommandProcess.ExitCode != 0)
{
...rest of the code
这里: -
FilePath --> C:\pstools\psexec.exe
Arguments --> \\servername -accepteula -u domain\userName -p password ipconfig (1)
\\servername -accepteula ipconfig (2)
(1) Gives Error 2250 (2) gives Error 5
同样的命令和代码与控制台应用程序工作。所以我相信这绝对是与Asp.net应用程序有关,它不能将凭证带到机器的远程。我的事件尝试startInfo.LoadUserProfile
但无济于事。
感谢您的帮助。我试图寻找类似的问题,但无法找到我面临的问题的解决方案。
1如果它与控制台一起使用,而不是asp Web应用程序,这听起来像是一个安全问题。 2你是否还检查.net版本是否正确?尝试使用.net 2.0在IIS上运行应用程序池(我今天遇到了这个问题)。 – gartenabfall 2013-04-30 19:05:53
我正在使用dotnet 4.0版。是的,它似乎更多的身份验证令牌没有结转...... – PSL 2013-04-30 19:07:20
IIS是否以与命令提示符相同的用户权限运行? – Powerslave 2013-05-09 21:28:05