如何从 LDAP 目录中检索仅包含自特定日期以来添加的用户和组的列表?
我的应用程序每天执行一次 LDAP 查询,并获取给定容器中的所有用户和组。获取后,我的应用程序将迭代组用户列表,仅将新用户添加到我的应用程序的数据库中(它仅添加用户名)。
如果有5万用户,我的应用服务器每天要忙45分钟执行这个操作。
有没有什么方法可以指定我在 LDAP 查询中需要一个“增量”,以便我只检索自上次 LDAP 查询以来添加/修改/删除的用户?
My application does an LDAP query once a day and fetches all the users and groups in a given container. Once it is fetched, my app goes iterates through the list of users of groups, adding only the new ones to my application's database (it adds only username).
If there are 50,000 users, my application server is busy for 45 minutes every day performing this operation.
Is there any way to specify that I need a "delta" in my LDAP query so that I retrieve only those users who got added/modified/deleted since my last LDAP query?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
我认为每个条目上都应该有一个
modifyTimestamp
。使用 Softerra LDAP 浏览器(http://download.softerra.com/files/ ldapbrowser26.msi)。如果存在,您应该能够向 ldap 查询添加一个条件,以查找自上次运行同步作业以来已更改的条目。I think there should be a
modifyTimestamp
on each entry. Take a peek with something like softerra ldap browser (http://download.softerra.com/files/ldapbrowser26.msi). If it exists you should be able to add a condition to your ldap query to look for entries that have been changed since you last ran the sync job.对于用户,请尝试:
对于组,请尝试:
然后:
注意:确保您的上次查询日期采用 UTC/Zulu 时间,或者使用“.nZ”后缀来调整您的时区。
For users try:
For groups try:
And then:
Note: be sure your last query date is in UTC/Zulu time OR use the ".nZ" suffix to adjust for your timezone.
这取决于您的目录。应该有一个属性,例如时间戳或序列号,您可以使用它来过滤 LDAP 查询。例如,在 Active Directory 中,该值为“uSNChanged”。
It depends on your directory. There should be an attribute such as a timestamp or sequence number that you can use to filter your LDAP query with. In Active Directory for instance, the value is 'uSNChanged'.
跟踪更改有两种主要选择:轮询和 DirSync。这些文章应该为您提供一些背景知识,并帮助您选择最适合您的内容。
http://support.microsoft.com/kb/891995
http://msdn.microsoft.com/en-us/library/ms677974(VS. 85).aspx
这是一些 .NET 内容:
http://msdn.microsoft.com/en-us/library/system.directoryservices.directorysynchronization.aspx
There are two main choices for tracking changes: polling and DirSync. These articles should give you some background and help you to choose what's best for you.
http://support.microsoft.com/kb/891995
http://msdn.microsoft.com/en-us/library/ms677974(VS.85).aspx
and here's some .NET stuff:
http://msdn.microsoft.com/en-us/library/system.directoryservices.directorysynchronization.aspx
您需要检查您的 Directory 的操作属性。
使用 OpenLDAP,您可以添加 + 号来获取操作属性并从 createTimestamp 进行检查:
它始终采用 Zulu 格式,即 YYYYMMDDHHMMSSZ。对于其他 DS(例如 fedora-ds),您需要搜索操作属性。
ldapsearch -x <;其他选项>创建时间戳
You need to check the operational attributes for your Directory .
With OpenLDAP you can add + sign to get operational attributes and check from createTimestamp:
It is always in Zulu format i.e. YYYYMMDDHHMMSSZ. With other DS like fedora-ds You need to search for the operation attribute.
ldapsearch -x < other_options > createTimestamp