Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

Troubleshooting
Research
Professional Opinions
Ask a Question
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

troubleshooting Question

Vbs script to get group membership count. Does not get actual count for some groups.

Avatar of bsharath
bsharathFlag for India asked on
Programming Languages-OtherScripting LanguagesVB Script
4 Comments1 Solution736 ViewsLast Modified:
Hi,

Vbs script to get group membership count. Does not get actual count for some groups.
For some groups that are 0 it gets the previously scanned group no's

Can anyone help to fix the issue.

REgards
sharath
On Error Resume Next
 
Const ADS_SCOPE_SUBTREE = 2
 
Set objConnection = CreateObject("ADODB.Connection")
Set objCommand =   CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
Set objCommand.ActiveConnection = objConnection
 
objCommand.Properties("Page Size") = 1000
objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE 
 
domainPath = "DC=lth,Dc=local"
orgUnitPathForGroups = "OU=Distri,OU=Offices"
 
objCommand.CommandText = _
    "SELECT Name FROM 'LDAP://" & orgUnitPathForGroups & "," & domainPath & "' WHERE objectCategory='group'"  
Set objGroupRecordSet = objCommand.Execute
 
objGroupRecordSet.MoveFirst
Do Until objGroupRecordSet.EOF
    
 
    Set objGroup = GetObject _
      ("LDAP://cn=" & objGroupRecordSet.Fields("Name").Value & "," & orgUnitPathForGroups & "," & domainPath)
    objGroup.GetInfo
 
    arrMemberOf = objGroup.GetEx("member")
 
    i = 0
'   WScript.Echo "Members:"
    For Each strMember in arrMemberOf
'        WScript.echo "   " & strMember
        i = i+1
    Next
 
    Wscript.Echo "Group: [" & objGroupRecordSet.Fields("Name").Value & "] Members: " & i
 
    objGroupRecordSet.MoveNext
Loop
ASKER CERTIFIED SOLUTION
Avatar of PFoeckeler
PFoeckeler

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Commented:
This problem has been solved!
Unlock 1 Answer and 4 Comments.
See Answers