C#.NET: Retrieve list of computers in a FOLDER in a domain
How do I Retrieve a list of computers in a FOLDER in a domain. lets say i have maydomain.dom as my domain and I have a folder contain开发者_如何学运维ing some computers.
Following code to list out computers in your domain and in active directory, this may help you
//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
It's not exactly the same but maybe you can use the same principle as in this blog post: Find users in Active Directory folder using GUID
精彩评论