Active Directory

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Bob Simoneau

    #1

    Active Directory

    Giving the Active Directory stucture below, how can I get a list of
    workstations using VB.NET 2005.

    DC=Simshop
    CN=Builtin
    CN=Account Operators
    CN=Administrato rs
    CN=Backup Operators
    CN=Distributed COM Users
    CN=Guests
    CN=Incoming Forest Trust Builders
    CN=Network Configuration Operators
    CN=Performance Log Users
    CN=Performance Monitor Users
    CN=Pre-Windows 2000 Compatible Access
    CN=Print Operators
    CN=Remote Desktop Users
    CN=Replicator
    CN=Server Operators
    CN=Terminal Server License Servers
    CN=Users
    CN=Windows Authorization Access Group
    CN=Computers
    CN=S888USAREG_1
    OU=Quick & Slow Canada
    OU=Servers
    OU=Users
    CN=s001ca Oakridge Centre
    CN=s002ca Pacific Centre
    CN=s003ca Metrotown
    CN=s004ca Richmond
    CN=s005ca Coquitlam
    CN=s010ca Market Mall
    CN=s011ca Bankers Hall
    CN=s012ca Southcentre Mall
    CN=s016ca West Edmonton Mall
    CN=s018ca Southgate Centre
    CN=s040ca Ste Foy
    CN=s041ca Place Montreal Trust
    CN=s042ca Ogilvy
    CN=s043ca Pointe Claire
    CN=s044ca Laval
    CN=s045ca St Bruno
    CN=s046ca Le Capital
    CN=s050ca Masonville
    CN=s053ca Devonshire
    CN=s054ca Kitchener
    CN=s056ca Limeridge
    CN=s060ca Rideau Centre
    CN=s061ca Bayshore Centre
    CN=s062ca St. Laurent Centre
    CN=s068ca Hazelton
    CN=s069ca Square One
    CN=s070ca Sherway Gardens
    CN=s071ca Scarborough
    CN=s075ca Eaton Centre
    CN=s076ca Yorkdale
    CN=s077ca Fairview
    CN=s079ca Upper Canada
    OU=Users with no policy
    CN=s015ca
    CN=s048ca
    CN=s052ca White Oaks
    CN=s073ca
    CN=s078ca
    CN=s600ca
    CN=s899ca
    OU=Workstations
    CN=S001CAREG_1
    CN=S001CAREG_2
    CN=S002CAREG_1
    CN=S002CAREG_2
    CN=S003CAREG_1
    CN=S003CAREG_2
    CN=S004CAREG_1
    CN=S004CAREG_2
    CN=S005CAREG_1
    CN=S005CAREG_2
    CN=S010CAREG_1
    CN=S010CAREG_2
    CN=S011CAREG_1
    CN=S011CAREG_2
    CN=S012CAREG_1
    CN=S012CAREG_2
    CN=S016CAREG_1
    CN=S016CAREG_2
    CN=S018CAREG_1
    CN=S018CAREG_2
    CN=S040CAREG_1
    CN=S040CAREG_2
    CN=S041CAREG_1
    CN=S041CAREG_2
    CN=S042CAREG_1
    CN=S042CAREG_2
    CN=S043CAREG_1
    CN=S043CAREG_2
    CN=S044CAREG_1
    CN=S044CAREG_2
    CN=S045CAREG_1
    CN=S045CAREG_2
    CN=S046CAREG_1
    CN=S046CAREG_2
    CN=S050CAREG_1
    CN=S050CAREG_2
    CN=S053CAREG_1
    CN=S053CAREG_2
    CN=S054CAREG_1
    CN=S054CAREG_2
    CN=S056CAREG_1
    CN=S056CAREG_2
    CN=S060CAREG_1
    CN=S060CAREG_2
    CN=S061CAREG_1
    CN=S061CAREG_2
    CN=S062CAREG_1
    CN=S062CAREG_2
    CN=S068CAREG_1
    CN=S068CAREG_2
    CN=S069CAREG_1
    CN=S069CAREG_2
    CN=S070CAREG_1
    CN=S070CAREG_2
    CN=S071CAREG_1
    CN=S071CAREG_2
    CN=S075CAREG_1
    CN=S075CAREG_2
    CN=S076CAREG_1
    CN=S076CAREG_2
    CN=S077CAREG_1
    CN=S077CAREG_2
    CN=S079CAREG_1
    CN=S079CAREG_2


  • Mark Keogh

    #2
    Re: Active Directory

    How about something like ....

    Imports System
    Imports System.Director yServices

    Module Module1

    Sub Main()

    Console.WriteLi ne("** Listing Start")

    Using oDirectoryEntry As DirectoryEntry = New DirectoryEntry( "LDAP://<your domain>")
    Using oDirectorySearc her As DirectorySearch er = New DirectorySearch er(oDirectoryEn try)

    oDirectorySearc her.Filter = ("(ObjectClass= Computer)")

    For Each oResult As SearchResult In oDirectorySearc her.FindAll
    Console.WriteLi ne(oResult.GetD irectoryEntry() .Name)
    Next

    End Using
    End Using

    Console.WriteLi ne("Listing End **")
    Console.ReadLin e()

    End Sub

    End Module

    Comment

    • Bob Simoneau

      #3
      Re: Active Directory

      I have used that code. That returns all computers. I am after the
      workstations section.

      "Mark Keogh" <m@ark.comwro te in message
      news:%23Y7bpQDw GHA.1436@TK2MSF TNGP02.phx.gbl. ..
      How about something like ....
      >
      Imports System
      Imports System.Director yServices
      >
      Module Module1
      >
      Sub Main()
      >
      Console.WriteLi ne("** Listing Start")
      >
      Using oDirectoryEntry As DirectoryEntry = New
      DirectoryEntry( "LDAP://<your domain>")
      Using oDirectorySearc her As DirectorySearch er = New
      DirectorySearch er(oDirectoryEn try)
      >
      oDirectorySearc her.Filter = ("(ObjectClass= Computer)")
      >
      For Each oResult As SearchResult In
      oDirectorySearc her.FindAll
      Console.WriteLi ne(oResult.GetD irectoryEntry() .Name)
      Next
      >
      End Using
      End Using
      >
      Console.WriteLi ne("Listing End **")
      Console.ReadLin e()
      >
      End Sub
      >
      End Module

      Comment

      • Peter Huang [MSFT]

        #4
        RE: Active Directory

        Hi Bob,

        In AD, there is no such a concept Workstations.
        So I understand you means the Entries in the OU WorkStations you created by
        yourself.

        Imports System
        Imports System.Director yServices

        Module Module1
        Sub Main()
        Using oDirectoryEntry As DirectoryEntry = New
        DirectoryEntry( "LDAP://OU=Workstations ,OU=Quick & Slow Canada,DC=Simsh op")
        For Each oEntry As DirectoryEntry In oDirectoryEntry .Children
        Console.WriteLi ne(oEntry.Name)
        Next
        End Using
        End Sub
        End Module

        NOTE: the LDAP path here may not be fully qualified for your scenario, if
        the path did not work, you may try to use the ADSI Editor tool to capture
        the concrete path.
        The ADSI support tool should be in your Product CD's
        Support/Tools/SUPTOOLS.MSI

        Best regards,

        Peter Huang

        Microsoft Online Community Support
        =============== =============== =============== =====
        When responding to posts, please "Reply to Group" via your newsreader so
        that others may learn and benefit from your issue.
        =============== =============== =============== =====
        This posting is provided "AS IS" with no warranties, and confers no rights.

        Comment

        • Bob Simoneau

          #5
          Re: Active Directory

          Thanks, that did it

          ""Peter Huang" [MSFT]" <v-phuang@online.m icrosoft.comwro te in message
          news:tEdosZOwGH A.4328@TK2MSFTN GXA01.phx.gbl.. .
          Hi Bob,
          >
          In AD, there is no such a concept Workstations.
          So I understand you means the Entries in the OU WorkStations you created
          by
          yourself.
          >
          Imports System
          Imports System.Director yServices
          >
          Module Module1
          Sub Main()
          Using oDirectoryEntry As DirectoryEntry = New
          DirectoryEntry( "LDAP://OU=Workstations ,OU=Quick & Slow Canada,DC=Simsh op")
          For Each oEntry As DirectoryEntry In oDirectoryEntry .Children
          Console.WriteLi ne(oEntry.Name)
          Next
          End Using
          End Sub
          End Module
          >
          NOTE: the LDAP path here may not be fully qualified for your scenario, if
          the path did not work, you may try to use the ADSI Editor tool to capture
          the concrete path.
          The ADSI support tool should be in your Product CD's
          Support/Tools/SUPTOOLS.MSI
          >
          Best regards,
          >
          Peter Huang
          >
          Microsoft Online Community Support
          =============== =============== =============== =====
          When responding to posts, please "Reply to Group" via your newsreader so
          that others may learn and benefit from your issue.
          =============== =============== =============== =====
          This posting is provided "AS IS" with no warranties, and confers no
          rights.
          >

          Comment

          Working...