Page 1 of 1 1
Topic Options
#208903 - 2014-05-15 01:54 PM fnLDAPQuery - AD Description field causes array error
PLeeman Offline
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:
 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:
 Code:
For $c = 0 to Ubound($aResults) 
    For $r = 0 to UBound($aResults,2) 
        $aResults[$c,$r] ? 
    Next 
    ? 
Next 

Top
#208906 - 2014-05-15 06:13 PM Re: fnLDAPQuery - AD Description field causes array error [Re: PLeeman]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
simple test, add this line:
? $c ' ' $r ' ' vartype($aResults) ' ' vartype($aResults[$c, $r])

right before:
$UserDetails = $UserDetails + "," + $aResults[$c, $r]

and when it bogs out, post the last output line on the console.
_________________________
!

download KiXnet

Top
#208910 - 2014-05-16 12:34 PM Re: fnLDAPQuery - AD Description field causes array error [Re: Lonkero]
PLeeman Offline
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:
 Code:
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 Administrator Offline
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:
 Code:
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 Offline
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
#208913 - 2014-05-16 03:47 PM Re: fnLDAPQuery - AD Description field causes array error [Re: PLeeman]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
yes, because it is an array, I added the carriage return AND line feed to see why it would be an array.
all documentation say it is actually string that is returned, so I still do not get why it would be an array.
_________________________
!

download KiXnet

Top
#208914 - 2014-05-16 05:10 PM Re: fnLDAPQuery - AD Description field causes array error [Re: Lonkero]
ShaneEP Moderator Offline
MM club member
*****

Registered: 2002-11-29
Posts: 2125
Loc: Tulsa, OK
Maybe kix is doing something weird like converting it to an array, if it returns and has commas in the description? Just a thought.
Top
#208915 - 2014-05-16 05:11 PM Re: fnLDAPQuery - AD Description field causes array error [Re: Lonkero]
PLeeman Offline
Just in Town

Registered: 2014-05-15
Posts: 4
Loc: UK
Ah, I understand. Thanks again.

Pete.

Top
#208916 - 2014-05-16 05:16 PM Re: fnLDAPQuery - AD Description field causes array error [Re: ShaneEP]
ShaneEP Moderator Offline
MM club member
*****

Registered: 2002-11-29
Posts: 2125
Loc: Tulsa, OK
Nope it's definitely not just Kix. If you google "ldap description type mismatch" there are a number of others that have run into the same problem.
Top
#208917 - 2014-05-16 05:17 PM Re: fnLDAPQuery - AD Description field causes array error [Re: ShaneEP]
ShaneEP Moderator Offline
MM club member
*****

Registered: 2002-11-29
Posts: 2125
Loc: Tulsa, OK
Someone posted this on one of the pages I read...

"The description attribute is a strange one, because technically it is
multi-valued, even though there is never more than one value. ADO retrieves
it as an string array with one value, or a Null if there is no value
assigned."

Top
#208919 - 2014-05-16 06:02 PM Re: fnLDAPQuery - AD Description field causes array error [Re: ShaneEP]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
wonder if you can assign an array to it \:\/
_________________________
!

download KiXnet

Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 530 anonymous users online.
Newest Members
Timothy, Jojo67, MaikSimon, kvn317, kixtarts2025
17874 Registered Users

Generated in 0.068 seconds in which 0.027 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org