【问题标题】:C#.NET: Retrieve list of computers in a FOLDER in a domainC#.NET:检索域中文件夹中的计算机列表
【发布时间】:2010-06-15 10:57:40
【问题描述】:

如何检索域中文件夹中的计算机列表。 假设我有 maydomain.dom 作为我的域 我有一个包含一些计算机的文件夹。

【问题讨论】:

    标签: c# .net-3.5 active-directory directoryservices


    【解决方案1】:

    以下代码列出您的域和活动目录中的计算机,这可能会对您有所帮助

    //ActiveDirectorySearch1
    //Displays all computer names in an Active Directory
    using System;
    using System.DirectoryServices; 
    namespace ActiveDirectorySearch1
    {
    class Class1
    {
    static void Main (string[] args)
    {
    //Note : microsoft is the name of my domain for testing purposes.
    DirectoryEntry entry = new DirectoryEntry(LDAP://microsoft);
    DirectorySearcher mySearcher = new DirectorySearcher(entry);
    mySearcher.Filter = ("(objectClass=computer)");
    Console.WriteLine("Listing of computers in the Active Directory"); 
    Console.WriteLine("============================================"); foreach(SearchResult resEnt in mySearcher.FindAll())
    { 
    Console.WriteLine(resEnt.GetDirectoryEntry().Name.ToString()); }
    Console.WriteLine("=========== End of Listing ============="); 
    }
    }
    }
    

    http://www.c-sharpcorner.com/UploadFile/jodonnell/ListAllComps07022005005654AM/ListAllComps.aspx

    【讨论】:

    • 谢谢,但我需要知道如何在我的域中的特定文件夹中获取计算机
    【解决方案2】:

    不完全一样,但也许你可以使用与这篇博文相同的原理:Find users in Active Directory folder using GUID

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-05-14
      • 2012-01-20
      • 2011-03-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多