Enumerate members of Administrators Group (AD)

  • Thread starter Thread starter BH Jodo Kast
  • Start date Start date
Your kidding right? I help you and you want to quibble?

I added the other fields to show you how to pull certain fields of data.
MemberOf is critical so you find those in the Administrative groups you are
seeking. Plus you don't want to load all properties if not necessary
especially if you have hundreds of users.

However you come up with your path is up to you. I am showing you how to do
it under a normal ad situation.
 
vbnetdev,
Just asking what you mean when you include:
dsUsers.PropertiesToLoad.Add("displayName")
No response from you, that's fine.

BTW: Check this out (works pretty good and no extra code)

Dim AD As New DirectoryEntry("WinNT://" +
Environment.MachineName + ",computer")
Dim group As DirectoryEntry =
AD.Children.Find("administrators", "group")
Dim members As Object = group.Invoke("Members", Nothing)
Dim member As Object
For Each member In CType(members, IEnumerable)
Dim x As New DirectoryEntry(member)
Response.Write(x.Name)
Next member

Simple huh? Done and done!
 
Glad you got it to work.

I added the properties I did so it only loaded the properties I wanted.
Otherwise it loads all hundred some of them. Your code loads everything. If
you only have a few users however that is no big deal.
 
Back
Top