Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Getting users from a large group

Status
Not open for further replies.

bisk

Technical User
May 22, 2007
13
CA
I seem to be having an issue when I query an AD group with more than 1500 users as only the first 1500 are returned.

Here's my code:
Domain = "Maple"
GroupName = "wts SSL VPN"

' Connection to AD
Set objCommand = CreateObject("ADODB.Command")
Set objConnection = CreateObject("ADODB.Connection")
objConnection.provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
objCommand.ActiveConnection = objConnection

strBase = "DC=" & Domain & ",DC=FG,DC=RBC,DC=COM"

objCommand.CommandText = _
"<GC://" & strBase & ">;" & _
"(&(objectCategory=group)" & _
"(sAMAccountName=" & GroupName & "));" & _
"DistinguishedName;subtree"

'On Error Resume Next
Err.Clear
Set objRecordSet = objCommand.Execute
If Err.Number Then
quit
End if

If objRecordSet.RecordCount = 0 Then
quit
Else
' Account found in AD, check attributes
strDN = objRecordSet.Fields("DistinguishedName")
set objGRoup = GetObject("LDAP://" & strDN)
objGroup.GetInfo

arrMemberOf = objGroup.GetEx("member")
For Each strMember in arrMemberOf
set Objuser = GetObject("LDAP://" & strMember)
Wscript.echo objuser.displayname & vbtab & strMember
Next

Set obGroup = nothing

End If
On Error Goto 0
Set objRecordSet = nothing

' Clear
objConnection.close
Set objConnection = nothing
Set objCommand = nothing
set objRecordSet = nothing
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top