Wrox Home  
Search P2P Archive for: Go

  Return to Index  

pro_vb thread: Drives and Network drives


Message #1 by Nigel Parker <Nigel.Parker@c...> on Wed, 31 Jul 2002 14:20:23 +0100
Nigel,

if you are still interested, these two methods return a collection of
domains/computers. It works on nt/2k, I do not have any other machine
to test it. I changed the code from the Q194115 MS knowledge base.

To use them you have to add the "Active DC Type Library" in the list
of References.
Be aware that 1) enumerate a remote network can take some time and
2) it returns all computers, even the one off line.
I did not put any error checking. Please take it as is...


Marco


Public Function EnumerateDomains() As Collection
    Dim ids As IADs
    Set ids = GetObject("WinNT:")
    ids.Filter = Array("Domain")
    Dim dm As IADsDomain
    Dim cs As Collection
    Set cs = New Collection
    For Each dm In ids
        cs.Add dm.Name
    Next
    Set EnumerateDomains = cs
End Function

Public Function EnumerateComputers(ByVal domain As String) As Collection
    Dim TheDomain As IADsDomain
    Dim Computer As IADsComputer
    Dim strDomain As String
    
    strDomain = "WinNT://" & domain

    Set TheDomain = GetObject(strDomain)
    TheDomain.Filter = Array("Computer")

    Dim cs As Collection
    Set cs = New Collection
    For Each Computer In TheDomain
        cs.Add Computer.Name
    Next Computer

    Set EnumerateComputers = cs
End Function


  Return to Index