【发布时间】:2014-03-10 07:32:17
【问题描述】:
我查看了有关以下异常原因的所有帖子:
An unhandled exception has occurred. at System.DirectoryServices.DirectoryEntry.Bind(Boolean throwIfFail) at System.DirectoryServices.DirectoryEntry.Bind() at System.DirectoryServices.DirectoryEntry.get_AdsObject() at System.DirectoryServices.DirectorySearcher.FindAll(Boolean findMoreThanOne) at System.DirectoryServices.DirectorySearcher.FindOne()
看来,这个问题的最佳解决方案是在调用 DirectorySearcher 时使用 HostingEnvironment.Impersonate(),如许多链接中所建议的,包括以下链接: Active Directory COM Exception - An operations error occurred (0x80072020) 和 Getting Error Querying Active Directory On The Server Only 我将用于访问 DirectorySearcher 的代码封装在 按照建议使用 (HostingEnvironment.Impersonate()) 并停止获取异常但找不到用户。 我看到它走得更远的唯一方法是在我的 web.config 文件中进行制作,但即使这样也没有获取正确的用户,应该是 windows 用户。 我需要更改 IIS 配置中的任何内容吗? 我应该提一下,与与该主题相关的其他帖子类似,此代码在我的本地环境中运行良好,即在其自己的 IIS 服务器上从 VStudio 运行。我只有在部署应用程序并尝试从另一台 IIS 服务器运行时才得到这个。 任何帮助将不胜感激。 谢谢。
【问题讨论】:
-
您找到解决方案了吗?
标签: c# asp.net-mvc-3 iis active-directory