我有一個控制檯應用程序,列表網站在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