【问题标题】:Searching global catalog搜索全局目录
【发布时间】:2009-09-17 15:20:08
【问题描述】:

如果我对全局目录进行查询(我打算使用 SDS.P),那么起始路径应该是什么,以便我可以搜索整个 GC?

例如,我想枚举 GC 中的所有用户。 假设我的 gc 有 3 个域的用户(一个父母,两个孩子):

TEST.COM
   ONE.TEST.COM
   TWO.TEST.COM

我在 ONE.TEST.COM 的计算机上。我不想硬编码 DC=XXX,DC=yyy,我想在运行时确定。

TIA! -会

【问题讨论】:

    标签: .net adsi


    【解决方案1】:

    这是一个查询全局目录的示例函数:

    class Program
        {
    
            static void Main()
            {
    
                DirectoryEntry entry = new DirectoryEntry("GC://dcserver.domain.local",
                                                           "utility",
                                                           "somepassword",
                                                           AuthenticationTypes.Secure );
    
                const string searchString = "(&(objectCategory=person)(objectClass=user))";
    
                DirectorySearcher searcher = new DirectorySearcher(entry, 
                                                                   searchString, 
                                                                   new string[] { "sAMAccountName", "cn" } );
    
                SearchResultCollection resultCollection = searcher.FindAll( );
    
                foreach ( SearchResult result in resultCollection )
                {
                    Console.WriteLine( result.Path + "\n" + 
                                       result.Properties["cn"][0] + "\n" + 
                                       result.Properties["samaccountname"][0]  );
                }
    
                Console.ReadLine( );
    
            }
       }
    

    【讨论】:

      猜你喜欢
      • 2018-03-20
      • 1970-01-01
      • 1970-01-01
      • 2016-12-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-09-22
      • 1970-01-01
      相关资源
      最近更新 更多