Results 1 to 3 of 3

Thread: LDAP - Get all dommains in forest

  1. #1

    Thread Starter
    New Member
    Join Date
    Dec 2008
    Posts
    3

    LDAP - Get all dommains in forest

    Hi!

    I am trying to get all domain names in the whole forest. Let me try to picture the scenario:

    **Entire directory
    ->Domain_1.com (my computer belongs to this domain!!)
    -Builtin
    -Computers
    -Domain Controllers
    -Subomain1.Domain_1.com
    -Subomain2.Domain_1.com
    -etc...
    **Domain_2.com
    **Domain_3.com

    I have tried the classic examples on the Internet, but all of them will get me everything under the Entire directory (because that's where my computer belongs).

    Now, what I need is to get the names for ALL domains, including the ones that are outside Entire Directory (Domain_2.com and Domain_3.com).

    I though I would be able to achieve this by calling the global directory, but it will still only get me info only for Domain_1.com
    vb Code:
    1. Private Sub GCTesting()
    2.     Dim oGC As IADs
    3.     Dim oDomainEnum As IADs
    4.     Dim oDomainBind As IADs
    5.     Dim oChild As IADs
    6.    
    7.     Set oGC = GetObject("GC:")
    8.     For Each oDomainEnum In oGC
    9.         ' Print the name of the domain.
    10.         Debug.Print oDomainEnum.Name
    11.        
    12.         ' Bind to the domain.
    13.         Set oDomainBind = GetObject("LDAP://" + oDomainEnum.Name)
    14.        
    15.         ' Enumerate the child objects of the domain.
    16.         For Each oChild In oDomainBind
    17.             Debug.Print "  " & oChild.Name
    18.         Next
    19.     Next
    20.    
    21. End Sub
    Is it actually possible to get all domain names (even the ones outside Entire Directory)? I think it should be possible somehow, since I can see the Domain_2.com and Domain_3.com by looking at the windows Location screen. So if I can see it from windows, I guess it should be also possible to do it from VB6.

    I appreciate any help on this

  2. #2
    Frenzied Member
    Join Date
    Mar 2009
    Posts
    1,182

    Re: LDAP - Get all dommains in forest

    found this...

    http://vbnet.mvps.org/index.html?cod...umprinters.htm

    but it says it is for enumerating printers, domains, print providers...

    but in the same search using my friends (yahoo, google, ask, answers, bing) I found this...

    http://pscode.com/vb/scripts/ShowCod...174&lngWId=-10



    Good Luck
    Option Explicit should not be an Option!

  3. #3

    Thread Starter
    New Member
    Join Date
    Dec 2008
    Posts
    3

    Re: LDAP - Get all dommains in forest

    Thanks a lot for the examples, but those will use old WinS API. LDAP is different from that.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width