OK - some issues that I see..

For your requirement, the sASsPath should be empty - try this snippet:
 Code:
$userinfo = 'testuser'
$aAttributes = 'AdsPath'
$sADsPath = ''
$sFilter = '(&(objectClass=user)(userPrincipalName=' + $userinfo + '*))'
$aResults = LDAPQuery($aAttributes, $sADsPath, $sFilter)

UBound($aResults) ' / ' UBound($aResults,2) @CRLF
If UBound($aResults) >= 0
  $aResults[0, 0] ?
EndIf
In the second part of your code, I'm not sure why you specify 20000 (I have a good guess), but it's not necessary. The entire substring process isn't necessary because the ADsPath is now empty - the "LDAP://" no longer needs to be trimmed. I should have read more of my original source before posting that example. Anyway - the other issue is that LDAPquery returns a 2-dimensaional array, which you aren't really processing. You're getting results by accident, actually.

Think of it like this - if you search for TestUser and have TestUser, TestUser1, and TestUser2, all 3 will be returned. Thus, the returning array will contain
TestUser:attribute...
TestUSer1:attributes...
etc..

That is why $aResults[$C, $R] is there - it is referencing the 2 dimension array. I'm not sure where you got $R and $C from, but you aren't controlling them. If you're sure that there is only one ID being retuned, just use [0, 0] as in my example.

Glenn
_________________________
Actually I am a Rocket Scientist! \:D