Getting computer names from my network locations

I was wondering if there is a way to get all the computer names that appear in my network locations using C #.

+3
source share
3 answers

You want to use the NetServerEnum () API. I do not believe that there is a managed shell in the .NET base libraries, but I was able to find this using a quick Google search: http://www.codeproject.com/Articles/16113/Retreiving-a-list-of-network- computer-names-using

NOTE. I have not tested or fully reviewed the code, but it should be sufficient for the starting point for what you need if there are any problems.

EDIT: DirectoryServices, . System.DirectoryServices - ADSI-, dosent Active Directory. NetServerEnum() , ( ). Computer Browser.

, , , :/

+3

, .:/

public List<String> ListNetworkComputers()
{
    List<String> _ComputerNames = new List<String>();
    String _ComputerSchema = "Computer";
    System.DirectoryServices.DirectoryEntry _WinNTDirectoryEntries = new System.DirectoryServices.DirectoryEntry("WinNT:");
    foreach (System.DirectoryServices.DirectoryEntry _AvailDomains in _WinNTDirectoryEntries.Children) {
        foreach (System.DirectoryServices.DirectoryEntry _PCNameEntry in _AvailDomains.Children) {
            if (_PCNameEntry.SchemaClassName.ToLower().Contains(_ComputerSchema.ToLower())) {
            _ComputerNames.Add(_PCNameEntry.Name);
            }
        }
    }
    return _ComputerNames;
}
+3

.

ActiveDirectory. .

System.DirectoryServices.

+2
source

All Articles