PDA

View Full Version : Which members are in a group (or a sub-group) (W2K)



kaokulk
01-15-2003, 08:07 AM
I have a group, like "IT Staff".

In it, I have groups called "LAN Administrator", "PC Support", "e-mail Admin", etc.

In "LAN Administrator", I have "Stan".

Is there a logon script that will tell me if "Stan" is in the "IT Staff" group? Most scripts I have found tell me that he is NOT in the "IT Staff" group.

ccoyne
02-04-2003, 05:42 AM
One of these scripts might work for you:

Enumerating Group Members
Retrieves the memberOf and primaryGroupID attributes of a user account to display group membership. Note that the primaryGroupID attribute contains an integer that maps to the name of the primary group. The memberOf attribute does not contain the name of the primary group of which the user is a member.


On Error Resume Next
Const E_ADS_PROPERTY_NOT_FOUND = &h8000500D
Set objOU = GetObject _
("LDAP://cn=Users,dc=NA,dc=fabrikam,dc=com")

ObjOU.Filter= Array("user")

For Each objUser in objOU
WScript.Echo objUser.cn & " is a member of: "
WScript.Echo vbTab & "Primary Group ID: " & _
objUser.Get("primaryGroupID")

arrMemberOf = objUser.GetEx("memberOf")

If Err.Number <> E_ADS_PROPERTY_NOT_FOUND Then
For Each Group in arrMemberOf
WScript.Echo vbTab & Group
Next
Else
WScript.Echo vbTab & "memberOf attribute is not set"
Err.Clear
End If
Wscript.Echo VbCrLf
Next

------------
Enumerating Local Groups and Their Members
Returns a list of local groups (and their members) found on a computer named atl-win2k-01.

strComputer = "atl-win2k-01"
Set colGroups = GetObject("WinNT://" & strComputer & "")
colGroups.Filter = Array("group")
For Each objGroup In colGroups
Wscript.Echo objGroup.Name
For Each objUser in objGroup.Members
Wscript.Echo vbTab & objUser.Name
Next
Next

-----------

ccoyne
02-04-2003, 06:14 AM
Here's another script that might work for you. I found it at: http://www.microsoft.com/technet/treeview/default.asp?url=/technet/ScriptCenter/user/ScrUG112.asp

Returns a list of all the local groups on the computer atl-win2k-01 that a user named kenmyer belongs to.
---------------

strComputer = "atl-win2k-01"
Set colGroups = GetObject("WinNT://" & strComputer & "")
colGroups.Filter = Array("group")
For Each objGroup In colGroups
For Each objUser in objGroup.Members
If objUser.name = "kenmyer" Then
Wscript.Echo objGroup.Name
End If
Next
Next

auntieflorrie
02-04-2003, 03:06 PM
res kit has tools for this.
technet Q137848