Solved

VBscript end of record set not finishing

Posted on 2014-01-16
4
480 Views
Last Modified: 2014-01-22
I’m not sure if this will make any sense.. but
 I’m making an VBscript that connects to Active Directory and then imports the records  into Sql.

The Record set is not looping all the way to the end.  It see all the records (+8000) in the logs but is doesn't make it pass 5000 records when writing to SQL or passed 7000 records when just writing to a TXT file instead of sql.

Any ideas?

Some of the code....
* the script does echo out the right number of records in AD.
Sub GetAttribs
	intCount = 1
	objCommand.CommandText = FormatLDAPString (UserOUString, "user", strFilter, strFields)
'WScript.Echo "Executing Query..."

	Set objRS = objCommand.Execute
'WScript.Echo "Records found:   " & objRS.RecordCount
'================================================================
	With objRS
		.MoveFirst
		Do Until .EOF
			strADUsername          = .Fields("sAMAccountName").Value
			‘more items listed if full script (23 total)
'===========================================
'Step: Write to SQL or Txt
'===========================================
' .......
'===========================================
'Step: End Loops
'===========================================
			intCount = intCount + 1
		    .MoveNext
		Loop
	End With
	objRS.Close

Open in new window

0
Comment
Question by:POOK-101
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 65

Accepted Solution

by:
RobSampson earned 250 total points
ID: 39787274
This is more often a result of the .PageSize property in the LDAP query.  It should be set to 1000 to allow more records to be returned.

As a simple test, can you just do this:
intRecord = 0
While Not objRS.EOF
   intRecord = intRecord + 1
   WScript.Echo intRecord
   objRS.MoveNext
Wend

Open in new window


and see the record count.

Regards,

Rob.
0
 

Assisted Solution

by:POOK-101
POOK-101 earned 0 total points
ID: 39789193
So i'm not sure why, but when i  hide the WScript.Echo command and the script finished with out problems. (all 8000 plus records)  I had about 15 different echo commands in the script.
Also i ran the script outside my VBS editor. (PrimalScipt)

How i hide the commands, so i can turn them back on if needed.

If iDebugMode = 1 Then WScript.Echo "Processing DB Functions Now"

Open in new window


Not sure why this worked.
0
 
LVL 65

Expert Comment

by:RobSampson
ID: 39790571
Not sure. If it was running under WScript, or was somehow hidden, maybe you couldn't see the echos. Glad it works anyway.
0
 

Author Closing Comment

by:POOK-101
ID: 39799476
I found the fix, but the reply gave me an idea of what to try.
0

Featured Post

Free NetCrunch network monitor licenses!

Only on Experts-Exchange: Sign-up for a free-trial and we'll send you your permanent license!

Here is what you get: 30 Nodes | Unlimited Sensors | No Time Restrictions | Absolutely FREE!

Act now. This offer ends July 14, 2017.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Recently, Microsoft released a best-practice guide for securing Active Directory. It's a whopping 300+ pages long. Those of us tasked with securing our company’s databases and systems would, ideally, have time to devote to learning the ins and outs…
Here's a look at newsworthy articles and community happenings during the last month.
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

688 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