Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > VB Script

Vista - Count a users groups

Reply
 
Old 03-12-2009   #1 (permalink)
Gunna


 
 

Count a users groups

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?

My System SpecsSystem Spec
Old 03-12-2009   #2 (permalink)
Richard Mueller [MVP]


 
 

Re: Count a users groups


"Gunna" <Gunna@xxxxxx> wrote in message
news:A34E5035-C15D-4F5A-998E-93B543926436@xxxxxx
Quote:

> 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
--


My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Remove Users From All Groups PowerShell
Users&Groups Vista General
Windows XP, Users and Groups PowerShell
How to do sysprep to make a image for my users and maintain the count on KMS server ? Vista installation & setup
How to do sysprep to make a image for my users and maintain the count on KMS server ? Vista General


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46