我有一个控制台应用程序,列表网站在IIS结合的DirectoryEntry 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
}
};
下,一切工作正常开发机器上Widows 7/IIS 7.5,但是当我在Windows 2012/IIS 8上测试时出现“Access is denied”错误。
错误日志
"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)"
PS应用程序池标识为 “ApplicationPoolIdentity”
我忘记说了,我的控制台应用程序正常工作我的服务器上,当我从CMD
我已经收到了这一个,如果我还记得,这个问题是要么在那里寻找AD服务器或凭据别没有正确的权限。这很烦人,因为它在本地工作正常 – Brian