| 
| 
| 
| #208903 - 2014-05-15 01:54 PM  fnLDAPQuery - AD Description field causes array error |  
| PLeeman   Just in Town
 
 Registered:  2014-05-15
 Posts: 4
 Loc:  UK
 | 
Hi.I'm using the fnLDAPQuery UDF to extract user details from our W2k3R2 AD. It was working brilliantly until I added "description" to the $aAttributes. The error I get is:
 ERROR : Error in expression: this type of array not supported in expressions.!
 Script: C:\Scripts\Kix\GetUsers.kix
 Line  : 31
 
 Line 31 is the 'else' line.
 
 I have modified the code slightly to return values for each user on one line separated by a comma, EG. Name,Department,Mail,Description. If I don't query for description it works great. I've tried the original code and get the same error.
 
 Any help greatly appreciated. Idiot Guide approach would be perfect :-)
 
 Pete.
 
 My Code:
 
 $aAttributes = "Name","Department","mail","Description"
$aResults = fnLDAPQuery($aAttributes,$sADsPath,$strFilter)
For $c = 0 to Ubound($aResults)
	For $r = 0 to UBound($aResults,2)
		If $r > 0 
			$UserDetails = $UserDetails + "," + $aResults[$c, $r]
		Else
			$UserDetails = $aResults[$c,$r]
		EndIf
	Next 
	$UserDetails ?
	$UserDetails = "" 
Next 
 Original Code:
 
 For $c = 0 to Ubound($aResults) 
    For $r = 0 to UBound($aResults,2) 
        $aResults[$c,$r] ? 
    Next 
    ? 
Next  |  
| Top |  |  |  |  
| 
| 
| #208910 - 2014-05-16 12:34 PM  Re: fnLDAPQuery - AD Description field causes array error
[Re:  Lonkero] |  
| PLeeman   Just in Town
 
 Registered:  2014-05-15
 Posts: 4
 Loc:  UK
 | 
Hi Lonkero, thanks for the response. I added the line as requested and ended up with the following:
 For $r = 0 to UBound($aResults,2)
	If $r > 0 
		? $c ' ' $r ' ' vartype($aResults) ' ' vartype($aResults[$c, $r])
		$UserDetails = $UserDetails + "," + $aResults[$c, $r]
	Else
		$UserDetails = $aResults[$c,$r]
	EndIf
Next 
 I ran the code and got the following output:
 0 1 8204 8
 0 2 8204 8
 0 3 8204 8204
 ERROR : Error in expression: this type of array not supported in expressions.!
 Script: C:\Scripts\Kix\GetUsers.kix
 Line  : 32
 
 
 Line 32 is the else line.
 
 I then ran again with description moved to the second attribute rather than the fourth and got the following:
 0 1 8204 8204
 ERROR : Error in expression: this type of array not supported in expressions.!
 Script: C:\Scripts\Kix\GetUsers.kix
 Line  : 32
 
 Thanks for any help you can provide.
 |  
| Top |  |  |  |  
| 
| 
| #208911 - 2014-05-16 02:15 PM  Re: fnLDAPQuery - AD Description field causes array error
[Re:  PLeeman] |  
| Lonkero   KiX Master Guru
 
       
 Registered:  2001-06-05
 Posts: 22346
 Loc:  OK
 | 
it means that the description you got in there is an array, which really doesn't make sense to me...what it returns with:
 
 
For $r = 0 to UBound($aResults,2)
	If $r = 0 
		$UserDetails = $aResults[$c,$r]
	Else
		if $r = 3
			$UserDetails = $UserDetails + "," + join($aResults[$c, $r],@crlf)
		else
			$UserDetails = $UserDetails + "," + $aResults[$c, $r]
		endif
	EndIf
Next 
 why is the description an array does not compute. when I write to it, I don't write an array, so indeed I would expect to get a string back as well...
 
_________________________! download KiXnet |  
| Top |  |  |  |  
| 
| 
| #208912 - 2014-05-16 02:55 PM  Re: fnLDAPQuery - AD Description field causes array error
[Re:  Lonkero] |  
| PLeeman   Just in Town
 
 Registered:  2014-05-15
 Posts: 4
 Loc:  UK
 | 
Thanks Lonkero, that has worked brilliantly :-)
 I understand that the script now checks if it is at position 4 ($r=3) so I'll make sure I take this into account when setting $aAttributes, but can you tell me why the script needs to add a line feed? is this because the description field is being seen as a list of things rather than a plain text field?
 
 Thanks again for your help.
 
 Pete.
 
 |  
| Top |  |  |  |  
| 
| 
| #208915 - 2014-05-16 05:11 PM  Re: fnLDAPQuery - AD Description field causes array error
[Re:  Lonkero] |  
| PLeeman   Just in Town
 
 Registered:  2014-05-15
 Posts: 4
 Loc:  UK
 | 
Ah, I understand.  Thanks again.
 Pete.
 
 |  
| Top |  |  |  |  
 Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
 
 | 
| 
 
| 0 registered
and 739 anonymous users online. 
 | 
 |  |