VBScript LDAP查询不会撤回所有结果

时间:2017-01-25 19:43:29

标签: vbscript active-directory ldap

我正在尝试在VBScript中针对AD运行LDAP查询。如果我没有设置属性“页面大小”它将返回结果但不是全部。我得到的记录数为960.但是,当我将页面大小设置为任何数字时,它似乎得到所有记录,因为现在我的计数是+5400。问题是所有记录都是空白的。

Set adoCommand = CreateObject("ADODB.Command")
Set adoConnection = CreateObject("ADODB.Connection")
adoConnection.Provider = "ADsDSOObject"
adoConnection.Open "Active Directory Provider"
Set adoCommand.ActiveConnection = adoConnection

' Search entire Active Directory domain.
Set objRootDSE = GetObject("LDAP://RootDSE")

strDNSDomain = objRootDSE.Get("defaultNamingContext")
strBase = "LDAP://" & strDNSDomain

strQuery = "Select " & strAttributes & " FROM '" & strBase & "' Where objectCategory = 'computer' OR objectCategory = 'user'"
adoCommand.CommandText = strQuery
adoCommand.Properties("Searchscope") = 2
adoCommand.Properties("Cache Results") = False 
adoCommand.Properties("Page Size") = 100 'Note if this is set to any number all results are blank
adoCommand.Properties("Size Limit") = 75000
adoCommand.Properties("Time Out") = 300

' Run the query.
Wscript.Echo "Running Query"
Set adoRecordset = adoCommand.Execute
Wscript.Echo "Finished Query"
Wscript.Echo adoRecordset.RecordCount 
'If "Page Size" is set to any number this will be +5400 but all records will be blank. If i don't set page size i get 960, the records aren't blank but i am not getting the 5400 total records

For i = 1 To adoRecordset.RecordCount
    name = adoRecordset.Fields("name").Value
    description = adoRecordset.Fields("description").Value
    displayName = adoRecordset.Fields("displayName").Value
    createOutputLine(Array(name,descritpion,displayName))'This just takes the result and writes it to a file
    adoRecordset.MoveNext
Next

adoRecordset.Close
adoConnection.Close

关于为什么我没有获得所有记录的任何想法?或者为什么如果我设置页面大小值为空?

0 个答案:

没有答案