we recently moved some scripts from a 32 bit Windows 2008 server to a new Windows 2008 server R2 64 bit machine. Now we have some trouble with a few VB Scripts. Let's take this one for example:

Set objcon = CreateObject("ADODB.Connection")
Set objrs = CreateObject("ADODB.Recordset")
Set objcom = CreateObject("ADODB.command")

Set objrootdse = GetObject("LDAP://RootDse")
strDN = "GC://" & objrootdse.Get("rootDomainNamingContext")

objcon.Provider = "ADsDSOObject"

objcon.Open "ADS Provider"
Set objcom.ActiveConnection = objcon
objcom.Properties("Page Size") = 10000
objcom.CommandText = "<" & strDN & ">;" & strFilter & ";adspath;subtree"

Set objrs = objcom.Execute

if objrs.eof and objrs.bof then //<-- fails here

When I run this script it fails with the exception: "The search filter cannot be recognized" although it runs fine on a 32 bit machine. The new server only has web role and file services role installed. There always seems to be some trouble when the ADsDSOObject provider is involved. The LDAP search filter is ok btw.

Edit: I also tried running the SysWow64 Versions of cmd.exe and cscript.exe with the same result.

Edit 2: Tried some more stuff. Turns out the method is right, it fails when it encounters a filter like "(&(name=)(objectClass=computer))" this is invalid since name cannot be empty in the LDAP string. Funny thing is, the other server seemed to ignore this error and just moved on.


Try running the script with the versions of wscript.exe or cscript.exe that are located in the directory %windir%\SysWOW64

  • Tried that, same result :( – hoetz Apr 20 '12 at 10:03
  • Code that you posted seems alright, but it's only a part of it. Can you post the complete code? – ZEDA-NL Apr 20 '12 at 11:46
  • New insight, see my edit. – hoetz Apr 20 '12 at 11:47
  • it's a strange world after all. – ZEDA-NL Apr 20 '12 at 11:58
  • Really crazy because now I have to update all the scripts with filter checks... – hoetz Apr 20 '12 at 12:08

I solved it: For some reason the Vbscript on the nwe server quit when encountering an invalid LDAP filter. It never did this on the old server so I guess something in the way those errors are handled changed with win 2008 r2.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.