• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 258
  • Last Modified:

Active Directory export exceeds 1000 records

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=*));" &_
"displayName,extensionAttribute6,legacyExchangeDN;subtree"

Set objRecordSet = objConnection.Execute(strLDAP)
MsgBox objRecordSet.RecordCount,0,"COUNT"
objRecordSet.MoveFirst
Do Until objRecordSet.EOF
   temp1=objRecordSet.Fields("displayName")
      temp2=objRecordSet.Fields("extensionAttribute6")
      temp3=objRecordSet.Fields("legacyExchangeDN")
      objFileHandle.WriteLine(temp1 & ";" & temp2 & ";" & temp3)
      objRecordSet.MoveNext
Loop

Can someone show me the code for an alternate method to get the data from a large database.
Thanks in advance
0
bleek
Asked:
bleek
  • 3
1 Solution
 
Netman66Commented:
This seems to be an issue no matter what tool is used:

http://support.microsoft.com/kb/888249/en-us


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

http://support.microsoft.com/?kbid=315071


Let me know.
0
 
bleekAuthor Commented:
I don't have the privilege to increase the size.  I can suggest it to the powers that be.  Thanks for the quick response.
0
 
bleekAuthor Commented:
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?
0
 
bleekAuthor Commented:
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"&_
   ",dc=dc2,dc=dc3,dc=dc4,dc=dc5l>;(&(!objectCategory=computer)(displayName=*)(extensionAttribute6=*)(legacyExchangeDN=*));displayName,extensionAttribute6,legacyExchangeDN;subtree"
 Set objRecordSet = objCommand.Execute
 objRecordSet.MoveFirst
 MsgBox "Finished search"
 Do Until objRecordSet.EOF
   objFileHandle.WriteLine(objRecordSet.Fields("displayName") & ";" & objRecordSet.Fields("extensionAttribute6") & ";" & objRecordSet.Fields("legacyExchangeDN"))
   objRecordSet.MoveNext
 Loop  


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.
0
 
GranModCommented:
Closed, 350 points refunded.
GranMod
The Experts Exchange
Community Support Moderator of all Ages
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now