Enumerating users in AD

  • Thread starter Thread starter NetworkElf
  • Start date Start date
N

NetworkElf

Hi all,

I'm looking for some example code that shows how to enumerate users with
vb.net. I'm trying to write an application that can read/write specific
properties of user objects in the directory.

I'm new to vb.net, so I need a nudge in the right direction to get me
rolling.

Thank you.
 
Ken Tucker said:
OK, the above link led me to some excellent reading. Some of it I even
understand... :p

This is the code I'm working with at the moment:


Dim last, first, email, userpath As String
Dim sizeLimit, pageSize As Integer
Dim entry As New
DirectoryServices.DirectoryEntry("LDAP://DC=whacko,DC=net")
Dim mySearcher As New
System.DirectoryServices.DirectorySearcher(entry)
Dim result As SearchResult
mySearcher.Filter = ("(objectClass=user)")

For Each result In mySearcher.FindAll()
userpath = result.GetDirectoryEntry().Path

lstLastName.Items.Add(userpath)
Next

First problem: I seem to have incorrectly specified the search filter, as
the search returns both user and computer objects.

Second problem: I'm uncertain how to take the LDAP path that gets stuffed
into userpath and get individual object properties (first and last name).

Another nudge would be appreciated.

Also any reading suggestions on vb.net and Active Directory (other than
MSDN) would be most appreciated.

Thanks -

ne.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top