Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hi

I've found following code forlisting all the computers in active directory:

'ActiveDirectorySearch1

'Displays all computer names in an Active Directory

'Written 08/26/02 - John O'Donnell - csharpconsulting@hotmail.com

Imports System

Imports System.DirectoryServices

Namespace ActiveDirectorySearch1

Class Class1

Shared Sub Main(ByVal args() As String)

'Note : microsoft is the name of my domain for testing purposes.

Dim enTry As DirectoryEnTry = New DirectoryEnTry("LDAP://microsoft")

Dim mySearcher As DirectorySearcher = New DirectorySearcher(enTry)

mySearcher.Filter = ("(objectClass=computer)")

Console.WriteLine("Listing of computers

in the Active Directory")

Console.WriteLine("===========

===========")

Dim resEnt As SearchResult

For Each resEnt In mySearcher.FindAll()

Console.WriteLine(resEnt.GetDirectoryEnTry().Name.ToString())

Next

Console.WriteLine("=========== End of Listing =============")

End Sub

End Class

End Namespace

 

but there is no system.directoryservices in my visual studio, why?

And how can I list all the computers in active directory?

Please help

Posted
You will also need to add a reference to System.DirectoryServices.dll.

Thank you

Sorry I've found it yesterday.

It works just fine but it brings back ALL the computer names in active directory is it possible to retrieve only computers which are currently in the network?

I would like to fill a combobox with it and have the user select a computer from it.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...