
|
email this FAQ to a colleague
Q:
How to I iterate through a list of users?
A:
Here is some script that will iterate through all the users of a particular group for a given domain. Change the variables strDomainName and strGroupName for the Domain and Group that you wish to iterate through.
Dim Dom
Dim Group
Dim Member
Dim strOutput
strDomainName="MachineName"
strGroupName="Administrators"
Set Domain = GetObject("WinNT://" & strDomainName)
Set Group = GetObject("WinNT://" & strDomainName & "/" & strGroupName)
For Each Member in Group.Members
strOutput=Null
If (Left(Member.Parent,8) = "WinNT://") then
strOutput = strOutput & Domain.Name & "," & GroupName & "," &_
Mid(Member.Parent,9,Len(Member.Parent)-8) & "\" &_
Member.Name & "," & Member.Class
Elseif Left(Member.Parent,7) = "LDAP://" then
strOutput = strOutput & Domain.Name & "," & GroupName & "," &_
Mid(Member.Parent,8,Len(Member.Parent)-7) &_
"\" & Member.Name &"," & Member.Class
Elseif (Left(Member.Parent,8) = Null) then
strOutput = strOutput & Domain.Name & "," & GroupName & "," &_
Member.Name &"," & Member.Class
End If
Next
- Wayne Berry
|