簡體   English   中英

使用HostingEnvironment.Impersonate()的Active Directory訪問無法找到用戶

[英]Active Directory access using HostingEnvironment.Impersonate() fails to find the user

我查看了每個帖子中有關以下異常的原因:

 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異常-發生操作錯誤(0x80072020),並且在查詢Active Directory時遇到錯誤僅服務器我按照建議使用(HostingEnvironment.Impersonate())封裝了用於訪問DirectorySearcher的代碼,它停止獲取異常,但找不到用戶。 我看到它進一步發展的唯一方法是在我的web.config文件中進行構建,但即使這樣也無法獲取正確的用戶,該用戶應該是Windows用戶。 我是否需要更改IIS配置中的任何內容? 我應該提到,與與此主題相關的其他帖子類似,此代碼在我的本地環境中也可以正常工作,即從VStudio在其自己的IIS服務器上運行。 我只有在部署應用程序並嘗試從其他IIS服務器運行時才得到此信息。 任何幫助將不勝感激。 謝謝。

仔細檢查您的LDAP路徑。

關於COM異常,我從“ AppPoolIdentity”切換為“ NetworkService”,這解決了我的問題。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM