> It looks like the Filter Property of the
> IADsMembers Object doesn't work at all.
> I used it to get a list of all groups, that
> are members of another group, but I still
> receive all users, too. I already searched
> MSDN for a bug report, but found nothing.
> Here's the code I used:
> Dim root As IADsGroup
> Dim members As IADsMembers
> Dim obj As IADs
> Set root = GetObject("WinNT://DOMAIN/Groupname")
> Set members = root.members
> members.Filter = Array("group")
> For Each obj In members
> MsgBox obj.Class + " " + obj.Name
First, the WinNT provider does not recognize groups as members of Global or
Universal security groups (such nested groups are not allowed in NT). WinNT
will recognize nested distribution groups and domain local groups. I assume
your group is a domain local group.
Next, the Members method returns a collection. I did not know it could be
treated as an object. I'm surprised there is a Filter method (or that an
error is not raised), but your are correct - it does nothing. The Filter
method is used with container objects, but a group is not a container, and
the Members collection is also not a container. However, you can use the
Class property method to get what you want.
Set objGroup = GetObject("WinNT://DOMAIN/Groupname,group")
For Each objMember In objGroup.Members
If objMember.Class = "Group" Then
Wscript.Echo objMember.Class & " - " & objMember.Name
I believe Filter is a method of IADsContainer objects, but not IADsMembers
Microsoft MVP Scripting and ADSI