Group Users List (1 Viewer)

KenHigg

Registered User
Local time
Today, 10:30
Joined
Jun 9, 2004
Messages
13,327
I need to get a list of all users (with their names) in a network user group - Any ideas where to start? I know the domain name and the group name - :)
 

Ron_dK

Cool bop aficionado
Local time
Today, 16:30
Joined
Sep 5, 2002
Messages
2,141
In MSDOS you could try :
get group groupname /dom

Hth
 

tehNellie

Registered User.
Local time
Today, 15:30
Joined
Apr 3, 2007
Messages
751
Assuming this is for active directory you can use something along the lines of

Code:
set objGroup = GetObject("LDAP://" & strgrpDN)

For each objmember in objgroup.members
 debug.print objmember.name 
next

Where strgrpDN is the distinguished name of the group in question.

The DN should be in the format CN=Groupname,OU=Groups,DC=myDomain,DC=com

I believe, off top of my head that objmember.class will tell you whether the member is a user or another group.

if you wanted to query a specific (non domain controller) server for local group information you can use a similar format:

Code:
set objGroup = GetObject("WinNT://192.168.0.1/Administrators")
You should also be able to use the machine name in place of the IP address
 
Last edited:

tehNellie

Registered User.
Local time
Today, 15:30
Joined
Apr 3, 2007
Messages
751
If this sort of thing is likely to land on your lap regularly, can I recommend the Active Directory Cook book from o'reilly.

Feel free to drop me a PM as I do a lot of gubbins around AD, groups and users, I don't get the time to drop by as much as I used to but I should receive a mail altert and I've a lot of VBA/S already set up to pull this sort of stuff.
 

KenHigg

Registered User
Local time
Today, 10:30
Joined
Jun 9, 2004
Messages
13,327
Hum... I just need a way to hit a button and find the users in a group so that we can review it every so often and delete users, etc...
 

tehNellie

Registered User.
Local time
Today, 15:30
Joined
Apr 3, 2007
Messages
751
Got something not a million miles away from that lurking around somewhere.

You looking to delete the user off the domain or just remove them from the group?
 

KenHigg

Registered User
Local time
Today, 10:30
Joined
Jun 9, 2004
Messages
13,327
I don't think I would have admin rights to all of that. We have managed workstations so I sure the system level stuff would be even more secure -
 

tehNellie

Registered User.
Local time
Today, 15:30
Joined
Apr 3, 2007
Messages
751
You should be able to query the domain at least even if it's only to produce a list of stuff that needs doing.
 

KenHigg

Registered User
Local time
Today, 10:30
Joined
Jun 9, 2004
Messages
13,327
So I tried the following code and got an error:

Code:
Dim strgrpDN As String
Dim objgroup As Object
Dim objmember As Property

strgrpDN = "CN=TOC_TURNOVER,OU=Groups,DC=Delta,DC=com"


Set objgroup = GetObject("LDAP://" & strgrpDN)

For Each objmember In objgroup.members
 Debug.Print objmember.Name
Next
 

tehNellie

Registered User.
Local time
Today, 15:30
Joined
Apr 3, 2007
Messages
751
So I tried the following code and got an error:

Code:
Dim strgrpDN As String
Dim objgroup As Object
[b]Dim objmember As Property[/b]

strgrpDN = "CN=TOC_TURNOVER,OU=Groups,DC=Delta,DC=com"


Set objgroup = GetObject("LDAP://" & strgrpDN)

For Each objmember In objgroup.members
 Debug.Print objmember.Name
Next

I get a type mismatch entering the For loop using your code, if I redeclare Objmember as an object it works fine here.
 

KenHigg

Registered User
Local time
Today, 10:30
Joined
Jun 9, 2004
Messages
13,327
Hum - I still get a Run-time error:

Automation error
A Referral was returned from the server

???
 

tehNellie

Registered User.
Local time
Today, 15:30
Joined
Apr 3, 2007
Messages
751
That's normally permissions in my experience.

I believe that by default an authenticated user of the Domain should normally be able to Read group membership information from the domain but this can be altered to improve security.
 

KenHigg

Registered User
Local time
Today, 10:30
Joined
Jun 9, 2004
Messages
13,327
Ok. Thanks. I kind of thought they'd have it locked up. Thanks for your help :)
 

Users who are viewing this thread

Top Bottom