Active directory 通过LDAP从Active Directory进行组导入

Active directory 通过LDAP从Active Directory进行组导入,active-directory,ldap,Active Directory,Ldap,我们使用LDAP根据大型Active Directory设置对用户进行身份验证。我们希望从Active Directory中提取所有组的列表,以便在本地数据库中镜像它们,并将用户的广告组映射到本地组 但是,当我们运行ldap查询以获取所有组的列表时,Active Directory会限制搜索的最大结果 鉴于查询结果大小的限制,获取此信息的最佳策略是什么?我们可以使用某种形式的查询分页吗 提前谢谢 A可以用来做这件事。关键是确保请求的页面大小不超过Active Directory实例的最大结果大小

我们使用LDAP根据大型Active Directory设置对用户进行身份验证。我们希望从Active Directory中提取所有组的列表,以便在本地数据库中镜像它们,并将用户的广告组映射到本地组

但是,当我们运行ldap查询以获取所有组的列表时,Active Directory会限制搜索的最大结果

鉴于查询结果大小的限制,获取此信息的最佳策略是什么?我们可以使用某种形式的查询分页吗

提前谢谢

A可以用来做这件事。关键是确保请求的页面大小不超过Active Directory实例的最大结果大小


例如,用于ADSI的ADO包装器会自动分页结果,可以找到其中的一个示例,不过很明显,根据您的技术堆栈,这可能适用于您,也可能不适用于您。

Active Directory支持分页控制。您必须参考Microsoft官方文章:ans,特别是如果您使用的是.NET 3.5及更高版本,您应该检查
System.DirectoryServices.AccountManagement
(S.DS.AM)命名空间。请在此处阅读所有相关内容:

您可以使用
PrincipalSearcher
和“示例查询”主体进行搜索:

// create your domain context
PrincipalContext ctx = new PrincipalContext(ContextType.Domain);

// define a "query-by-example" principal - here, we search for any GroupPrincipal 
GroupPrincipal qbeGroup = new GroupPrincipal(ctx);

// create your principal searcher passing in the QBE principal    
PrincipalSearcher srch = new PrincipalSearcher(qbeGroup);

// to get around the 1'000 or so object limit - you need to "go deep" and
// set the page size on the underlying DirectorySearcher to e.g. 500
(searcher.GetUnderlyingSearcher() as DirectorySearcher).PageSize = 500;

// find all matches
foreach(var found in srch.FindAll())
{
    // do whatever here - "found" is of type "Principal" - it could be user, group, computer.....          
}

您可以在
GroupPrincipal
上指定任何属性,并将其用作
PrincipalSearcher
的“示例查询”

您使用的是什么语言或脚本?我们使用的是python。谢谢