Search for subgroups within a group using ADSI

I am trying to get the groups included in another group using ADSI. In the principal group  I have users and groups on it. I´m trying to get these groups included on the principal filtering the members collection, but i'm not getting the collection filtered. I'm using following code:

Dim adsgroup As ActiveDs.IADsGroup
      Dim adsSubGroup As ActiveDs.IADs
      Dim sFilter() As String

            adsgroup = GetObject(sFormattedGroupName)
            ReDim Preserve sFilter(0)
            sFilter(0) = "Group"
            adsMembers = adsgroup.Members

            adsMembers.Filter = sFilter

            For Each adsMembers In adsMembers


Can anyone tell me why this is not working?

Thank you
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

There could be members of members, so use a function that recall itself if that appends


  sFilter(0) = ("(objectClass=group)")

remember that filter is case sensitive, so the class type and the classname are case sensitive
purbanoAuthor Commented:
Thank you Dranizz, but I'm afraid it doesn't work.

Any other idea.

Use the DirectoryServices.Dll reference
and use the DirectorySearcher class

look at this

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Bob LearnedCommented:
No comment has been added lately, so it's time to clean up this TA.
I will leave the following recommendation for this question in the Cleanup topic area:

Accept: Dranizz {http:#9771795}

Please leave any comments here within the next seven days.

EE Cleanup Volunteer
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.