捕获 ActiveDirectory“addUser” C# 中的事件?
我们的系统具有“自动登录”功能。
因此,如果我在 AD 中创建一个新用户“John”,那么 John 就能够访问 Intranet 网站(我们查询 AD 以查看当前用户是否在 AD 中)。
但是
我们还有一个users
表(SQL Server),它需要有新用户的FirstName
和LastName
用户。
每次在 AD 中创建新用户时,我们希望更新Users
表 - 应运行一些 C# 代码将相关数据输入 SQL Server(以及其他一些内容)。
我怎样才能捕获“AD 中的新用户已创建”事件?
We have the ability of "AutoLogin" in our systems.
So if I create a new user in AD as "John" - then John has the ability to access the intranet web site ( we query AD to see if the current user is in AD).
But
We also have a users
table (SQL Server) which needs to have the FirstName
and LastName
of the new user.
We want to update that Users
table each time a new user in AD is created - some C# code should be run to enter the relevant data into SQL Server (and some other things).
HOw can I catch the event of "new user in AD created" ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
查看 Ryan Dunn 的精彩博客文章:
在 .NET 中实现更改通知
,该文章涉及这个主题。他提供了三个选项:
更改通知轮询更改,并显示了每个选项的优缺点,以及第三个选项(更改通知)的一些 C# 代码。
Check out Ryan Dunn's excellent blog post:
Implementing Change Notifications in .NET
that deals with this exact topic. He offers three options:
and shows pros and cons for each of the options, and some C# code for the third option (Change Notifications).
您可以使用 C# 中的 System.DirectoryServices.Protocols.DirectoryNotificationControl 来实现此目的,这样您就不必轮询 AD 的更改。
WMI 可能是您可以深入研究的第二个解决方案。它存在 AD WMI 提供程序。 使用WMI监控AD给你一些线索。本文所做的内容并没有超出您到目前为止所了解的内容,但我认为使用 WMI 事件您可以创建所需的通知。您可以在监控 Active Directory 运行状况中找到有关此内容的 Microsoft 信息,< a href="http://technet.microsoft.com/en-us/library/cc180914.aspx" rel="nofollow">特殊的 Active Directory WMI 提供程序。
You can use System.DirectoryServices.Protocols.DirectoryNotificationControl from C# for this purpose so you don't have to poll AD for changes.
WMI is perhaps a second solution you can dig in.It exists AD WMI Providers. Using WMI to Monitor AD gives you some clues about that. This article don't do more than what you get so far, but I think that with WMI events you can create the notifications you need. You can find Microsoft informations about this begining in Monitoring Active Directory Health, especialy Active Directory WMI Providers.
如果不将添加新用户的实际函数包装到某种 C# 例程中,您不太可能捕获此类事件。如果您沿着这条路线走下去,您可以同时将所使用的添加到 AD 和 mysql。
另一种选择是轮询 AD 用户并对照现有 mysql 用户进行检查,并在找到时添加新用户。
It is unlikely that you can capture that kind of event without wrapping the actual function of adding the new user into some kind of c# routine. If you go down this route, you can add the used to AD and mysql at the same time.
Another option would be to poll the AD users and check this against the existing mysql users and add new when found.