在執行廣告搜索時,我已經收到COM異常的ASP.NET 4.0:發生操作錯誤(0x80072020)ApplicationPoolIdentity權限和UserPrincipal
線程Active Directory COM Exception - An operations error occurred (0x80072020) 我指出了正確的方向 - 中描述的問題與權限有關。
作爲解決方法,我將Application Pool Identity從ApplicationPoolIdentity切換到NetworkService,並能夠無誤地執行查詢。 令人困惑的是,在同一個域上的另一個IIS7 Web服務器上,我能夠將Application Pool Identity保留爲ApplicationPoolIdentity。
有什麼,我失蹤,使這個查詢工作使用ApplicationPoolIdentity?
FWIW,代碼是相當簡單:
PrincipalContext context = new PrincipalContext(ContextType.Domain, theDomain);
UserPrincipal p_up = new UserPrincipal(context);
p_up.GivenName = "John"; //error occurred here
p_up.Surname = "Doe";
PrincipalSearcher ps = new PrincipalSearcher(p_up);
PrincipalSearchResult<Principal> psr = ps.FindAll();