【问题标题】:Group import from Active Directory via LDAP通过 LDAP 从 Active Directory 导入组
【发布时间】:2011-11-05 12:54:29
【问题描述】:

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

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

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

提前致谢!

【问题讨论】:

  • 您使用什么语言或脚本?
  • 我们正在使用python。谢谢

标签: active-directory ldap


【解决方案1】:

Active-Directory 支持分页控制。一定要参考微软官方文章:Searching the Directory尤其是Search Size and Page Size

【讨论】:

    【解决方案2】:

    simple paged results query 可用于执行此操作。关键是确保请求的页面大小不超过 Active Directory 实例的最大结果大小。

    例如,ADSI 的 ADO 包装器会自动分页结果,其中一个示例可以在 here 找到,但显然这可能对您有用,也可能不适用,具体取决于您的技术堆栈。

    【讨论】:

      【解决方案3】:

      如果您使用的是 .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 的“示例查询”。

      【讨论】:

        猜你喜欢
        • 2013-01-26
        • 1970-01-01
        • 1970-01-01
        • 2015-09-11
        • 2010-09-26
        • 1970-01-01
        • 2015-10-20
        • 1970-01-01
        • 2019-08-19
        相关资源
        最近更新 更多