代码之家  ›  专栏  ›  技术社区  ›  davidsleeps

SearchResultCollection的GetDirectoryEntry是否必须再次查询ActiveDirectory?[目录服务/.net]

  •  0
  • davidsleeps  · 技术社区  · 16 年前

    在.NET中使用DirectorySearcher的findall()方法时,searchResultCollection的getDirectoryEntry()方法是否需要另一次到Active Directory的访问?例如。。。。

    Dim src As SearchResultCollection
    Dim ds As New DirectorySearcher
    ' code to setup DirectorySearcher
    
    
    ' go to Active Directory and fill collection with results
    src = ds.FindAll()
    
    '...later on in code or whatever
    ' does the next line of code require another trip to Active Directory?
    Dim de As DirectoryEntry = src.item(0).GetDirectoryEntry()
    
    2 回复  |  直到 16 年前
        1
  •  0
  •   tvanfosson    16 年前

    根据文档,它将重新请求ad以获取目录条目。

    Reference

    在需要时使用GetDirectoryEntry 查看实时条目而不是 返回的条目 或者当你想的时候 对对象调用一个方法 返回。

    注: 对通过DirectorySearch返回的每个搜索结果调用GetDirectoryEntry可能很慢。

        2
  •  0
  •   marc_s MisterSmith    16 年前

    是的,它将返回到AD并获取整个DirectoryEntry对象。

    如果您想避免这种情况(并且您应该尽可能地),请在您的 DirectorySearcher 使用 PropertiesToLoad 收集,然后检查 SearchResult.Properties 对于这些值-这些值将随搜索返回,不需要再次往返于Active Directory。

    马克