返回首页

您好!

在这里,我创建的代码从Active Directory中的所有用户
我不知道什么问题,有

try

{

   string path = "LDAP://usihgdgfui";

   string filter = "(&(objectCategory=person))";

   string[] propertiesToLoad = new string[1] { "name" };

 

   using (DirectoryEntry root = new DirectoryEntry(path, "xx\\xxxx", "xxxx"))

   using (DirectorySearcher searcher = new DirectorySearcher(root, filter, propertiesToLoad))

   using (SearchResultCollection results = searcher.FindAll())

   {

      foreach (SearchResult result in results)

      {

         string name = (string)result.Properties["name"][0];

                        

         comboBox1.Items.Add(name);

      }

   }

}

catch

{

}

回答

评论会员: 时间:2
G