System.DirectoryServices.AccountManagement not working on the server

五迷三道 提交于 2019-12-06 16:42:22

After some research, I found the following link: http://social.msdn.microsoft.com/Forums/en-US/netfxbcl/thread/c314650a-ff5e-49e6-8f53-9a7cca17e806

In it one user describes the solution to the problem:

I have seen this error and it is related to the fact that when using NTLM authentication and impersonation set to true in web.config, IIS cannot use the authenticated token against another server since it is a "secondary token".

The solution to my issue was to wrap my Active Directory code with:

 using( HostingEnvironment.Impersonate() )
 {
    //Active Directory search goes here.
 }

This makes the call to AD with the identity of the application pool, and it did the trick in my case.

I was just looking around to fix the error System.DirectoryServices.DirectoryServicesCOMException

after using UserPrincipal.FindByIdentity

and the answer from mlsteeves was what i needed, impersonating the hostenvironnement on the production server!

So good call this was about delegation on server and your solution was perfect thanks alot!

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!