I think the key is to enumerate the Properties collection of each child node in the collection of DirectoryEntry children. While there may be a more elegant way of doing so, the way that I was able to get a list of users, for example, was to do something like this:
Dim entry As New DirectoryServices.DirectoryEntry
For Each child As DirectoryServices.DirectoryEntry In entry.Children
Dim propertyValue As Integer = 0
Try
propertyValue = CType(child.Properties("UserFlags").Value, Integer)
Catch ex As Exception
' if it throws an exception, it's not a user item
propertyValue = 0
End Try
If (propertyValue = 513) Then
Console.WriteLine(child.Name)
End If
Next
If you look at the property names in the Properties collection, you should be able to isolate which ones are Domains, which ones are workgroups and which ones are users, etc. I believe there may be a more elegant solution, but I haven't found the best reference for that solution yet. What a piece of work is man, how noble in reason, how infinite in faculties, in form and moving how express and admirable . . . and yet to me, what is this quintessence of dust? -- Hamlet, Act II, Scene ii.