Hi,

I'm running the following KIX code snippet:

 Code:
break on
$AttrName = "memberof"
$ObjName = "TestUser"

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

  ; define initial vars for items to be read
  $objRootDSE = GetObject("LDAP://rootDSE") 
  $defaultNamingContext = $objRootDSE.Get("defaultNamingContext")
  
  ; define the query statement  
  $objCommand.CommandText = "Select $AttrName from 'LDAP://$defaultNamingContext' WHERE sAMAccountName='" + $ObjName + "'"

  ; and execute it
  $Recordset = $objCommand.Execute

  $strURL = $Recordset.Fields("$AttrName").Value
 
   for $x = 0 to ubound($strURL)
    $arrGROUP = split($strURL[$x],",")
    $GROUP = SUBSTR($arrGROUP[0],4,len($arrGROUP[0])-3)
    $UserIsMemberOf = $UserIsMemberOf + $GROUP + ";"
  Next
  
  ? $UserIsMemberOf

  $objConnection.close


The purpose is to query a individual user's specific AD attribute via LDAP (memberOf is just an example to retrieve a list). The query is in this SQL statement:
"Select MemberOf from 'LDAP://DC=my,DC=domain,DC=com' WHERE sAMAccountName='TestUser'"
(sent via LDAP to the AD)

Running this code in WinXP gives me the attribute content, running it on Win7-64 fails entirely ! (both Kix32 V4.62)

The first failing line in Win7 is this:
$defaultNamingContext = $objRootDSE.Get("defaultNamingContext")

It seems to choke on the ("defaultNamingContext") - in debug mode, this part appears as screen output ! Is there something wrong with .GET, or passing/appending a parameter ?

Replacing this by the NamingContext literal string for a test, it runs until here:
$strURL = $Recordset.Fields("$AttrName").Value

Here, it trips over ("$AttrName").Value, and drops out with "ERROR: Unexpected command!".

Do I miss something, or what's wrong here ? I thought this kind of stuff is just passed tru to the OS ? At least it works fine if the same things are coded in VBS ... no problems there with the ADO queries. Still, I need to keep this in KIX, as it is part of a login script which is supposed to run on WinXP and Win7 - nope, I don't want/intend to replace it by something else ...

This is driving me mad ... could anybody be so kind and help me out of this ?

Thanks a bundle !

Andy