I saw a question in a forum asking how to enumerate computers available in a domain. Though it might seem little difficult, it can be accomplished in less than 10 line of code. Thought would make it as a post for everyone’s benefit. Here we go:
public void PrintComputersInDomain (string domainName)
DirectoryEntry de = new DirectoryEntry ("LDAP://" + domainName);
foreach (DirectoryEntry c in de.Children)
Please note when you try this code, it might take seconds to finish if there are hundreds of computers in the given domain (of course, you can always do “kill process” J).
As announced earlier by Scott Gu, the source code for most of the namespaces in the .NET framework is available. This means that you can now step into the framework source code while debugging your applications and see its actual implementation. I had a chance to play around with this few weeks ago (thanks Shawn for sharing the setup instructions). There were few delays while debugging because of framework source code download over internet but otherwise, it was pretty smooth and neat. As the title of this blog says, the purpose of this source code release is more for debugging and seeing the code for better understanding of how the whole things works.
Follow the detailed setup instructions and see it for yourself.