Active Directory export exceeds 1000 records

Posted on 2006-04-26
Last Modified: 2011-09-20
Here's the script I have.  It works until it reaches 1000 records then it quits.

strDomain = InputBox("Input Domain Name")
strFile = strDomain & "Mailbox.txt"
set objFso = wscript.createObject("Scripting.FileSystemObject")
set objFileHandle = objFso.OpenTextFile(strFile,2,"True")

Set objConnection = CreateObject("ADODB.Connection")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "ADs Provider"
strLDAP="<GC://dc=one,dc=two,dc=com>;(&(objectCategory=person)(objectClass=user)(displayName=*));" &_

Set objRecordSet = objConnection.Execute(strLDAP)
MsgBox objRecordSet.RecordCount,0,"COUNT"
Do Until objRecordSet.EOF
      objFileHandle.WriteLine(temp1 & ";" & temp2 & ";" & temp3)

Can someone show me the code for an alternate method to get the data from a large database.
Thanks in advance
Question by:bleek
    LVL 51

    Expert Comment

    This seems to be an issue no matter what tool is used:

    You can try to increase the MaxPageSize within the AD using NTDSUTIL:

    Let me know.

    Author Comment

    I don't have the privilege to increase the size.  I can suggest it to the powers that be.  Thanks for the quick response.

    Author Comment

    Someone told me that there is a way to enable paging in the search so that you don't have to increase the MaxPageSize (which was turned down in no uncertain terms!).  Can anyone help me with the code to do this?

    Author Comment

    I found the solution:  

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

      objCommand.Properties("Page Size") = 900
      objCommand.Properties("SearchScope") = ADS_SCOPE_SUBTREE
      objCommand.Properties("Timeout") = 1200

      objCommand.CommandText = "<GC://dc=dc1"&_
     Set objRecordSet = objCommand.Execute
     MsgBox "Finished search"
     Do Until objRecordSet.EOF
       objFileHandle.WriteLine(objRecordSet.Fields("displayName") & ";" & objRecordSet.Fields("extensionAttribute6") & ";" & objRecordSet.Fields("legacyExchangeDN"))

    The important thing is to set the page size < 1000 and set a timeout value large enough so that it won't timeout.

    If nobody has any objections, I will ask to have the question closed and the points refunded.  I'll wait 1 week to give people time.

    Accepted Solution

    Closed, 350 points refunded.
    The Experts Exchange
    Community Support Moderator of all Ages

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    I guess it is not common knowledge to most Wintel engineers/administrators: If you have an SNMP-based monitoring system in your environment (and it's common to have SNMP or Syslog) it's reasonably easy to enable monitoring of the Windows Event logs,…
    Many of us need to configure DHCP server(s) in their environment. We can do that simply via DHCP console on server or using MMC snap-in on each computer with Administrative Tools installed in a network. But what if we have to configure many DHCP ser…
    Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
    Here's a very brief overview of the methods PRTG Network Monitor ( offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now