i need to list all the server (sql server) and all the server as well / workstation ............... netserverenum is not working in dot net can you help me in this
Printable View
i need to list all the server (sql server) and all the server as well / workstation ............... netserverenum is not working in dot net can you help me in this
I think this Code Snippet will show you the right way.
VB Code:
Sub ListComputersOnNetwork() ' Returns a list of all computers on the network ' and places the results in a listview Dim Path As String = "WinNT://RAXPHQ" ' Edit the path to fit your domain/workgroup Dim Domain As New System.DirectoryServices.DirectoryEntry(Path) ' If you want to login as a specific user to get the list, ' you could use the following constructor: ' Dim Domain As New System.DirectoryServices.DirectoryEntry(Path, UserName, Password) Dim Computers As DirectoryServices.DirectoryEntries = Domain.Children Computers.SchemaFilter.Add("Computer") Dim Computer As DirectoryServices.DirectoryEntry Dim tmpItem As ListViewItem For Each Computer In Computers tmpItem = ListView1.Items.Add(Computer.Name) tmpItem.SubItems.Add(Computer.Path) Next End Sub
greetz
Cheffe0815
Cheffe0815
thanks ! for the code but i have another problem in your code i can get the list of computer with the give "path" but what i need is the list of workgroups or domain / to supply it in the path can you help me with this
thanks
Try this one
VB Code:
' Gets a list of Domain names the user can see on the network. ' Needs a Reference to System.DirectoryServices. Public Shared Function ListDomainsInNetwork() As ArrayList Dim networkDomains As System.DirectoryServices.DirectoryEntry = _ New System.DirectoryServices.DirectoryEntry("WinNT:") Dim domain As System.DirectoryServices.DirectoryEntry Dim domains As New ArrayList() 'Populate the array with the list of domains For Each domain In networkDomains.Children domains.Add(domain.Name) domain.Close() Next Return domains End Function
greetz
Cheffe0815
cheffe0815
thanks again pal !!!!
thanks pal ! can you help me again with this one
how can i know what operation system running in each computer list or is the computer a client or server
thanks