Active Directory

B

Bob Simoneau

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=Administrators
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
 
M

Mark Keogh

How about something like ....

Imports System
Imports System.DirectoryServices

Module Module1

Sub Main()

Console.WriteLine("** Listing Start")

Using oDirectoryEntry As DirectoryEntry = New DirectoryEntry("LDAP://<your domain>")
Using oDirectorySearcher As DirectorySearcher = New DirectorySearcher(oDirectoryEntry)

oDirectorySearcher.Filter = ("(ObjectClass=Computer)")

For Each oResult As SearchResult In oDirectorySearcher.FindAll
Console.WriteLine(oResult.GetDirectoryEntry().Name)
Next

End Using
End Using

Console.WriteLine("Listing End **")
Console.ReadLine()

End Sub

End Module
 
B

Bob Simoneau

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

Peter Huang [MSFT]

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.DirectoryServices

Module Module1
Sub Main()
Using oDirectoryEntry As DirectoryEntry = New
DirectoryEntry("LDAP://OU=Workstations,OU=Quick & Slow Canada,DC=Simshop")
For Each oEntry As DirectoryEntry In oDirectoryEntry.Children
Console.WriteLine(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.
 
Top