Enumerate members of Administrators Group (AD)

V

vbnetdev

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

BH Jodo Kast

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!
 
V

vbnetdev

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.
 

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

Top