views:

66

answers:

2

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 containing some computers.

+1  A: 

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

Pranay Rana
Thanks but I need to know how get the computers in a SPECIFIC FOLDER in my domain
Alon Amir
+1  A: 

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

ho1