Hey people got a small problem with my script. I'm trying to query an account name, first of all it querires an oracle database then it should query the active directory. the problem is i get an error message "IDispatch pointers not allowed in expressions!"

I think the problem is that i'm useing periods in a varible. any advice on how to resolve this issue

 Code:
Function fn_testAD()

Dim $cn, $cmd, $rs, $cnstring, $cmdtext, $selectedProperties, $propertynames, $oCn, $oCmd, $oRS, $i
$cnstring = 'Provider=MSDAORA;Password=password;User ID=user;Data Source=source;Persist Security Info=True;'
							
$cmdtext = "SELECT DISTINCT PEOPLE.PERSON_CODE, PEOPLE.FORENAME, PEOPLE.SURNAME, PEOPLE_UNITS.UNIT_INSTANCE_CODE, PEOPLE_UNITS.CALOCC_CODE FROM PEOPLE INNER Join PEOPLE_UNITS ON PEOPLE.PERSON_CODE = PEOPLE_UNITS.PERSON_CODE and PEOPLE_UNITS.UNIT_TYPE = 'R' and PEOPLE_UNITS.CALOCC_CODE = '09' and length(PEOPLE_UNITS.UNIT_INSTANCE_CODE) = '6' "
$cn = CreateObject("adodb.connection") 
$cmd = CreateObject("adodb.command") 
$cn.connectionstring = $cnstring 
$cn.Open 
$cmd.activeconnection = $cn 
$cmd.commandtext = $cmdtext 
$selectedProperties = "ADsPath"
$propertynames = Split($selectedProperties, ",")

$oCn = CreateObject("ADODB.Connection")
$oCmd = CreateObject("ADODB.Command")
$oCn.Provider = "ADsDSOObject"
$ = $oCn.Open("Active Directory Provider", "", "", -1)
$oCmd.ActiveConnection = $oCn
$oCmd.Properties("Page Size").Value = 1000
$oCmd.Properties("Searchscope").Value = 2 ;ADS_SCOPE_SUBTREE							
$rs = CreateObject("adodb.recordset") 
$rs.cursortype = 3 
$rs.locktype = 3 
$rs.Open($cmd)
While Not $rs.EOF And Not $rs.BOF
														
															
	? "PERSON_CODE: " + $rs.Fields.Item("PERSON_CODE").Value
	? "FORENAME: " + $rs.Fields.Item("FORENAME").Value
	? "SURNAME: " + $rs.Fields.Item("SURNAME").Value
	? "YEAR: " + $rs.Fields.Item("CALOCC_CODE").Value
	? "GROUP: " + $rs.Fields.Item("UNIT_INSTANCE_CODE").Value
	? " "			
	$Tempname = $rs.Fields.Item("PERSON_CODE").Value
	? $Tempname

 $oCmd.CommandText = "SELECT " + $selectedProperties + " FROM 'LDAP://student.domain.co.uk/DC=student,DC=domain,DC=co,DC=uk' WHERE objectCategory='user' and objectClass = 'user' AND sAMAccountName = '$Tempname' ORDER BY Name"
$oRS = $oCmd.Execute
; While Not $oRS.EOF
	$obj = GetObject($oRS.Fields($propertynames[0]))
	? "CN Name: " +  + $obj.cn 
	? "First Name: " + $obj.givenname
	? "Surname: " + $obj.sn
	? "Login Name: " + $obj.sAMAccountName	
	? "Email: " + $obj.mail 
	? "Home Directory: " + $obj.homeDirectory	
	? " "								
	$Tempname = $rs.Fields.Item("PERSON_CODE").Value
	? $Tempname
	Sleep 2							
				
	 $rs.MoveNext
 ; Loop				
										
$rs.Close
$cn.Close
			
EndFunction


it fails on this line.

$obj = GetObject($oRS.Fields($propertynames[0]))

However If I remove the varible $Tempname in the active directory and change it to a static name it works

Any help much appreciated.

Thanks

Glyn


Edited by 5861king (2010-05-10 04:41 PM)