Hi

I would like to know how to get a list of computer's account in active directory
have you a sample please ?

thank

balou

RE: retrieve computer account in active directory by mohan_ran

mohan_ran
Wed Jun 02 10:41:03 CDT 2004

Hi

You can retreive computer accounts (COU, if I'm not mistaken) using the following code snippet (in C#)
//E.g., domainName = "microsoft.com/DC=microsoft,DC=com"
DirectoryEntry deSearcher = new DirectoryEntry("GC://" + domainName, userName, password)
DirectorySearcher dsSearcher = new DirectorySearcher(deSearcher);
dsSearcher.Filter = "(objectCategory=organizationalUnit)"
dsSearcher.PropertiesToLoad.Add("canonicalName")
foreach(SearchResult srResult in dsSearcher.FindAll()

//Retrieve the COU name
//srResult.Properties["canonicalName"][0]
}