Hi Richard H.

I done the VarTypeName() on $tempname i am assuming thats correct.
I am also the $tempname is workingas i'm running this bit of code.

 Code:
$Tempname = $rs.Fields.Item("PERSON_CODE").Value
	? $Tempname


from this bit of code a number is returned which it does for example
when running ? $tempname it reports back on the console as

9847430

therefore I would assusme useing $tempname would work in the active directory as show below

 Code:
$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 = '9847430' ORDER BY Name"



now if change the code to the folowing it works

 Code:
$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"


so I'm not to sure what is going wrong?


Edited by 5861king (2010-05-11 11:25 AM)