Tried that... even with pagesize set, all searches stop at 1000... I must be
doing something wrong, I can never get paging to work with my returned
recordsets... which is even more horrible when you have auditors and you
hand them an incomplete query! That's why I had to do it. We only have
approx. 1300 users here. Missing 300 does not go unnoticed.
Can you post known working code that utilizes pagesize assuming I want EVERY
user account for the BaseDN of DC=tcorp,DC=com?
Here's one original blurb of code that I can't seem to modify to return
pages:
Dim objConn, objRecordSet
Dim strDomain, strQuery
Set objConn = CreateObject("ADODB.Connection")
objConn.Provider = "ADsDSOOBJECT"
objConn.Open "ADs Provider"
Set objRootDSE = GetObject("LDAP://RootDSE")
strDNSDomain = objRootDSE.Get("defaultNamingContext")
strFilter =
"(&(objectClass=person)(objectClass=user)(objectCategory=Person))"
strQuery = "<LDAP://tcorp.com/" & strDNSDomain & ">;" & strFilter &
";cn,userAccountControl,sn,givenName,name,sAMAccountName;subtree"
Set objRecordSet = objConn.Execute(strQuery)
objRecordset.MoveFirst
While Not objRecordSet.EOF
<...>
Wend
Here's another blurb that utilizes pagesize (from KB 269361) that doesn't
work either:
const adUseClient=3
const adOpenStatic = 3
const adLockOptimistic = 3
const adLockReadOnly = 1
const adCmdText = 1
const adFilterFetchedRecords = 3
Dim cn, cmd, rs, lcConn, i, j
set cn = CreateObject("ADODB.Connection")
set cmd = CreateObject("ADODB.Command")
set rs = CreateObject("ADODB.RecordSet")
lcConn = "Provider=ADsDSOObject"
With cn
.Open lcConn
End With
With rs
Set .ActiveConnection = cn
.CursorLocation = adUseClient
.CursorType = adOpenStatic
.LockType = adLockOptimistic
.PageSize = 2000 '<--- this is the value to change for how many records
to return.
.CacheSize = .PageSize
.Open
LDAP://dcsvr001.tcorp.com:389;(objectClass=organizationalPerson);cn,adspath;
subtree, , adOpenStatic, adLockReadOnly, adCmdText
.AbsolutePage = 1
.Filter = adFilterFetchedRecords
End With
For i = 0 To rs.RecordCount - 1
For j = 0 To rs.Fields.Count - 1
WScript.Echo rs.Fields(j).Value 'not the real code obviously
Next
WScript.Echo
rs.MoveNext
Next
Can you fix the code or point out working code? Thanks!