我有一个控制台应用程序,其中列出了IIS中的网站绑定
using (var directoryEntry = new DirectoryEntry("IIS://localhost/w3svc/" + GetWebSiteId())) {
var bindings = directoryEntry.Properties["ServerBindings"];
}我通过进程从ASP.NET调用这个控制台应用程序
var process = new Process {
StartInfo = new ProcessStartInfo {
FileName = "c:/app.exe",
Arguments = "check",
UseShellExecute = false,
RedirectStandardOutput = true,
CreateNoWindow = true
}
};在Widows7/IIS7.5下的开发机器上,一切正常,但是当我在Windows 2012 / IIS 8上测试时,获得“访问被拒绝”的错误。
错误日志
"System.Runtime.InteropServices.COMException (0x80070005): Access is denied.
at System.DirectoryServices.DirectoryEntry.Bind(Boolean throwIfFail)
at System.DirectoryServices.DirectoryEntry.Bind()
at System.DirectoryServices.DirectoryEntry.get_IsContainer()
at System.DirectoryServices.DirectoryEntries.ChildEnumerator..ctor(DirectoryEntry container)
at System.DirectoryServices.DirectoryEntries.GetEnumerator()
at IISSubdomainManagement.Program.GetWebSiteId()
at IISSubdomainManagement.Program.TotalBindings()
at IISSubdomainManagement.Program.Main(String[] args)"p.s应用程序池标识为"ApplicationPoolIdentity“
我忘了提到,当我从CMD运行我的控制台应用程序时,它在我的服务器上正常工作。
发布于 2013-01-15 22:36:44
您需要授予IUSR帐户访问和执行C:\app.exe的权限。这个链接应向您提供必要的信息,以找到正确的帐户。
发布于 2013-01-15 22:51:17
您可能已经将权限授予了“ApplicationPoolIdentity”,而不是实际对应于该应用程序池的虚拟帐户。阅读微软的描述或在线搜索虚拟标识IIS等。
在您的开发机器上,您可能拥有某种完全的管理权限,因此它没有那么受限制。
如果在此之后仍然有问题,我建议在运行过程监视器时复制错误,这样您就可以确切地看到哪个进程正在使用哪个标识访问哪个资源。但是,我建议在开发机器上复制这个问题,而不是在产品上运行Process。它需要一点学习才能有效地运行它。
发布于 2014-06-26 21:36:01
在IIS7/8 go 控制面板中,/ Program和Features功能打开或关闭,检查从: Web管理工具中的所有项目(包括:,II 6管理兼容性)
https://stackoverflow.com/questions/14348141
复制相似问题