Notify me when events in Active Directory occur in C#

时间秒杀一切 提交于 2020-01-06 03:49:05

问题


I need to get notification when certain events occur in Active Directory using LDAP protocol. Events that should be triggered are:

  • When a certain AD group is associated to a user.
  • And if a field (like phone number) has changed in AD user.

I searched all internet but mostly solutions are based on the code on the end of this article:

  • Registering change notification with Active Directory using C#

As mentioned in that article there are 3 ways to do it:

  • Using USNChanged
  • Using the DirSync Control
  • And using that code on the end of the page.

For first two options I found articles with examples on Microsoft's site, but all examples are in c++, and I need this in C#.

Other code samples that I found are incomplete and not understandable, so I can't use them appropriate.

Is there any solution, code sample etc that I can use similar to that code on the end of provided article?

Once again, I need this in C#

Thanks


回答1:


I want to share what I have accomplished so far. So since I managed to set the notifiers on my Active directory using 3rd solution from provided article:

  • Registering change notification with Active Directory using C#

I realized that (even though its mentioned in post) its possible to register only 5 objects in domain - I'm not exactly sure why, but there is some limitation on server. I solved that with the next line of code:

notifier.Register("dc=a24xrmdomain,dc=info",System.DirectoryServices.Protocols.SearchScope.Subtree);

that is I set the root domain to be observed and set the scope of monitoring to System.DirectoryServices.Protocols.SearchScope.Subtree) - all child's.

I found out that monitoring of Active directory on this way is not a best practice because in case if there is a lot of users - 10k for example not all changes will be triggered. So since you have to have previous state of object that you want to monitor you can use some of the other two methods from provided link to accomplish this task. I assume that you have to set some timer for every 5sec for example and check the appropriate field of the object.



来源:https://stackoverflow.com/questions/39261263/notify-me-when-events-in-active-directory-occur-in-c-sharp

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