C#中发生Active Directory中的事件时通知我 [英] Notify me when events in Active Directory occur in C#

查看:171
本文介绍了C#中发生Active Directory中的事件时通知我的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当使用LDAP协议在Active Directory中发生某些事件时,我需要获取通知.应该触发的事件是:

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

  • 当某个AD组与用户相关联时.
  • 如果AD用户中的字段(如电话号码)已更改.

我搜索了所有互联网,但大多数解决方案都是基于本文结尾处的代码:

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

如该文章所述,有3种方法可以做到:

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

  • 使用USNChanged
  • 使用DirSync控件
  • 并在页面末尾使用该代码.

在前两个选项中,我在Microsoft网站上找到了带有示例的文章,但是所有示例都使用c ++,因此我需要在C#中使用.

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?

再一次,我在C#中需要这个

Once again, I need this in C#

谢谢

推荐答案

我想分享我到目前为止所取得的成就.因此,由于我使用提供的文章中的第3种解决方案在Active Directory上设置了通知程序:

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:

我意识到(即使在文章中提到了它)可以在域中仅注册5个对象-我不确定为什么,但是对服务器有一些限制.我用下一行代码解决了这个问题:

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);

也就是说,我将根域设置为要观察,并将监视范围设置为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.

我发现以这种方式监视Active Directory并不是最佳实践,因为如果有很多用户,例如10k,则不会触发所有更改.因此,由于必须具有要监视的对象的先前状态,因此可以使用提供的链接中的其他两种方法来完成此任务.我假设您必须例如每5秒设置一个计时器,并检查对象的适当字段.

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.

这篇关于C#中发生Active Directory中的事件时通知我的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆