"Gunna" <Gunna@xxxxxx> wrote in message
news:A34E5035-C15D-4F5A-998E-93B543926436@xxxxxx
> Hi,
>
> Im tying to enumerate the members of a partiular group and then for each
> member of that group count the total number of groups they belong too. I
> think im right to enumerate the group members and then I figured id need
> to
> do some kind of action for each member of the group to count the number of
> groups they belong too.
>
> Can anyone offer some guidance? If you bind to the group you can use the Members method of the group object
to enumerate all direct members. The Members method returns a collection of
object references to the members, so you can retrieve other information
about the members. For example, you can use the memberOf attribute of each
member object to enumerate the DN's of the groups they are members of. There
is no way to retrieve a count, so you must enumerate each DN and count. For
example:
==========
Option Explicit
Dim objGroup, objMember, strGroup, lngCount
Set objGroup = GetObject("LDAP://cn=MyGroup,ou=West,dc=MyDomain,dc=com")
For Each objMember In objGroup.Members
lngCount = 0
For Each strGroup In objMember.memberOf
lngCount = lngCount + 1
Next
Wscript.Echo objMember.sAMAccountName & " is a member of " _
& CStr(lngCount) & " groups."
Next
--
Richard Mueller
MVP Directory Services
Hilltop Lab -
http://www.rlmueller.net
--