How to List Computers in a Domain

peterrexj

New member
Joined
Sep 5, 2005
Messages
1
Programming Experience
1-3
I have tried to list the comuters using the ActiveDs library but there is a error while looping. Is there any other way to find out the computers that are connected to a Domain or WorkGroup.
 
i wouldnt mind knowing how to list all the computer's in the same workgroup (as the one running the app)

i'll do a quick google search on this, perhaps i'll find something

also welcome to the forums
 
This is not my code, but was from a free source code on the internet. I had been searching for how to send messages using the Net Send command in dos, but stumbled apon this code in the progress. I am not sure if this is what you want, but here it is:

The final result looks a bit like this (minus the blur :))

[edit] found the source: http://www.codeproject.com/vb/net/MyLanApp.asp [/edit]
DomainList.jpg



for this code sample you need a treeview on the form called TreeView1

VB.NET:
	   Dim childEntry As DirectoryEntry
		Dim ParentEntry As New DirectoryEntry()
		Try
			ParentEntry.Path = "WinNT:"
			For Each childEntry In ParentEntry.Children
			    Dim newNode As New TreeNode(childEntry.Name)
			    Select Case childEntry.SchemaClassName
					Case "Domain"
					 Dim ParentDomain As New TreeNode(childEntry.Name)
					 TreeView1.Nodes.AddRange(New TreeNode() {ParentDomain})

					 Dim SubChildEntry As DirectoryEntry
					 Dim SubParentEntry As New DirectoryEntry()
					 SubParentEntry.Path = "WinNT://" & childEntry.Name
					 For Each SubChildEntry In SubParentEntry.Children
						 Dim newNode1 As New TreeNode(SubChildEntry.Name)
						 Select Case SubChildEntry.SchemaClassName
							 Case "Computer"
								 ParentDomain.Nodes.Add(newNode1)
						 End Select
					    Next
				End Select
			Next
		Catch Excep As Exception
			MsgBox("Error While Reading Directories")
		Finally
			ParentEntry = Nothing
		End Try
 
Back
Top