搜索DirectoryServices以按日期返回已修改用户的列表 [英] Searching DirectoryServices to return a list of modified users by date

查看:78
本文介绍了搜索DirectoryServices以按日期返回已修改用户的列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个很大的LDAP目录,当前正在从中返回所有用户.我们遍历用户列表,比较在本地保存的内容,以查找不再存在的或新的内容,然后在本地创建/删除它们.

We have a large LDAP directory that we're currently returning all users from. We iterate through the list of users, and compare what we've saved locally to find those that either no-longer exist, or that are new, then create/delete them locally.

问题在于此操作需要HOURS才能完成.

The problem is that this operation takes HOURS to complete.

我认为解决方案是为Directory Services定义一个更具体的搜索查询,并仅返回最近24小时(或上一次运行的时间)已被修改的那些用户.不幸的是,我很难找到要使用哪个属性来使搜索查询更具体.

I think the solution to this would be to define a more specific search query to Directory Services and only return those users that have been modified in the last 24 hours (or whenever it last ran). Unfortunately I'm having difficulty finding which property to use in order to make the search query more specific.

我查看了此可用属性列表,但是我能看到的唯一可能是'ms-DFS-Last-Modified-v2',但是,我不确定如何使用它.

I've looked at this list of available properties, but all I can see that might work is 'ms-DFS-Last-Modified-v2', however, I'm not sure how to use it.

还有其他想法吗?

我们当前用于搜索的代码如下:

The code we're using to search currently is below:

            PrincipalContext domainContext = new PrincipalContext(ContextType.Domain, "MYDOMAIN", "dc=MYDOMAIN,dc=co,dc=za");
            UserPrincipal theuser = new UserPrincipal(domainContext);

            theuser.Name = "*";

            // create a principal searcher for running a search operation
            PrincipalSearcher pS = new PrincipalSearcher(theuser);

            // assign the query filter property for the principal object 
            pS.QueryFilter = theuser;

            // run the query
            PrincipalSearchResult<Principal> theresults = pS.FindAll();
            retUsers = new List<ActiveDirectoryUser>();
            List<UserPrincipal> copyUsers = new List<UserPrincipal>();
            copyUsers = theresults.OfType<UserPrincipal>().Where(userresult => userresult.EmailAddress != null).ToList();


            foreach (UserPrincipal result in copyUsers)
            {
               ... process users.
            }

推荐答案

使用以下LDAP过滤器属性可以解决此问题:

This was resolved by using these LDAP filter properties:

修改时间:2014年7月10日上午8:35:17

Modified : 7/10/2014 8:35:17 AM

modifyTimeStamp:2014年7月10日上午8:35:17

modifyTimeStamp : 7/10/2014 8:35:17 AM

通过遵循 查看全文

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