I have couple of groups with more than 1500 (some group have 2000+). I need
to get the list of members and be able to a Text file. I tried first using
DSQuery to list the DNs og members, using following command:
dsquery * -filter "&(objectClass=Group)(name=group_name)" -scope subtree
-attr member
I was only able to view first 1500 members only. I tried with other group
names too, with same results.
I then wrote a script to get this information, and that too, returned only
1500 members!! I think there is something I am missing, and your help is
needed to get that "something". Thanks in advance..
Here is a copy of my script:
'---------------------------------------------
'On Error Resume Next
Const E_ADS_PROPERTY_NOT_FOUND = &h8000500D
dim fs, ts
set fs = createObject("Scripting.fileSystemObject")
set objArgs=wscript.Arguments
strFile = objArgs(0) 'Text file containing list of group names, to get
members of.
set ts = fs.openTextFile(strFile)
while not ts.atEndOfStream
strGroup = trim(ts.readLine)
Set objGroup = GetObject (getObjectDN("group","name",strGroup))
arrMembers = objGroup.GetEx("member")
strSam=""
If Err.Number = E_ADS_PROPERTY_NOT_FOUND Then
WScript.Echo "Group " & strGroup & " has no members."
Else
WScript.Echo "Group: " & strGroup & " has following members: "
For Each m in arrMembers
set objGrp = getObject("LDAP://" & m)
strSam = strSam & objGrp.samAccountName & "," & objGrp.displayName
& vbNewLine
Next
wscript.echo strSam
End If
wend
function getObjectDN(objType,strProp,strval)
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") = 2000
objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE
objCommand.CommandText = "SELECT * FROM 'LDAP://dc=test,dc=myDomain,dc=com'
WHERE objectCategory='" & objType &
"' and '" & strProp & "'='" & strVal & "'"
Set objRecordSet = objCommand.Execute
objRecordSet.MoveFirst
getObjectDN=objRecordSet.Fields("adsPath").Value
end function
'------------------------------------------------------------
--
Umesh
"Old programmers never die. They just terminate and stay resident."
Bookmarks