Discussion:
Type mismatch error using WScript.Echo
(too old to reply)
Paul E. Surette
2003-11-25 17:22:29 UTC
Permalink
Hello all,

The following code gives me a "VBScript runtime error: Type mismatch" error
when I try to display the msExchMailboxGuid. The msExchMailboxGuid is an
Octet String value and looks something like this in ADSI Edit: 27 A3 4D 55
83 02 09 4C 9E F1 2C 26 06 17 25 01

How can I read this value for this script?

========Script Start===========

Set objUser = GetObject ("LDAP://CN=Test User,OU=test OU,DC=test,DC=com")

objUser.GetInfo

WScript.Echo "Extension Attribute 1: " & objUser.extensionAttribute1
WScript.Echo "msExchMailboxGuid: " & objUser.msExchMailboxGuid
WScript.Echo "First name: " & objUser.givenName
WScript.Echo "Last Name: " & objUser.sn
Wscript.Echo "Display Name: " & objUser.displayName
Wscript.Echo "Alais: " & objUser.mailNickname
WScript.Echo "Email address: " & objUser.mail
WScript.Echo "User ID: " & objUser.sAMAccountName

========Script End===========
Alex K. Angelopoulos [Server MVP]
2003-11-25 18:28:00 UTC
Permalink
Post by Paul E. Surette
Hello all,
The following code gives me a "VBScript runtime error: Type mismatch"
error when I try to display the msExchMailboxGuid. The
msExchMailboxGuid is an Octet String value and looks something like
this in ADSI Edit: 27 A3 4D 55 83 02 09 4C 9E F1 2C 26 06 17 25 01
WScript.Echo "msExchMailboxGuid: " & objUser.msExchMailboxGuid
It's an array. Echo it out like this:
WScript.Echo Join(objUser.msExchMailboxGuid)
Paul E. Surette
2003-11-25 18:44:40 UTC
Permalink
Thanks for the response.

However when I try the suggestion I get the following:

Variable uses an Automation type not supported in VBScript

When I do a WScript.Echo varType(objUser.msExchMailboxGuid) I get a 8209 for
the return value. This tells me it's an array:

vbByte 17
vbArray 8192

8192 + 17 = 8209

Any other suggestions?
Post by Alex K. Angelopoulos [Server MVP]
Post by Paul E. Surette
Hello all,
The following code gives me a "VBScript runtime error: Type mismatch"
error when I try to display the msExchMailboxGuid. The
msExchMailboxGuid is an Octet String value and looks something like
this in ADSI Edit: 27 A3 4D 55 83 02 09 4C 9E F1 2C 26 06 17 25 01
WScript.Echo "msExchMailboxGuid: " & objUser.msExchMailboxGuid
WScript.Echo Join(objUser.msExchMailboxGuid)
Tom Lavedas
2003-11-25 19:57:00 UTC
Permalink
That's an array of bytes, which is not directly supported,
but some resourceful type (going my the moniker of lil
endian, I believe) worked out an algorithm that can decode
these. It is painfully slow for very large byte arrays,
but is okay for shorter ones, like that encountered here.
Here is my slight variation on the theme that makes it
quite a bit faster - suitable for arrays up to several
KB ...

' ...
wsh.echo C8209toStr(objUser.msExchMailboxGuid)

Function C8209toStr(body8209)
Dim aOut(UBound(body8209)), i
For i = 1 to UBound(body8209) + 1
aOut(i-1) = chr(ascb(midb(body8209,i,1)))
Next
C8209toStr = Join(aOut, "")
End Function

For large byte arrays the ADO (v2.5+) ByteStream is the
prefered solution - or maybe in all cases, if you're
comfortable with the ADO control, which I am not ;0)

Tom Lavedas
===========
-----Original Message-----
Thanks for the response.
Variable uses an Automation type not supported in VBScript
When I do a WScript.Echo varType
(objUser.msExchMailboxGuid) I get a 8209 for
vbByte 17
vbArray 8192
8192 + 17 = 8209
Any other suggestions?
"Alex K. Angelopoulos [Server MVP]" <aka-at-mvps-dot-org>
Post by Alex K. Angelopoulos [Server MVP]
Post by Paul E. Surette
Hello all,
The following code gives me a "VBScript runtime
error: Type mismatch"
Post by Alex K. Angelopoulos [Server MVP]
Post by Paul E. Surette
error when I try to display the msExchMailboxGuid.
The
Post by Alex K. Angelopoulos [Server MVP]
Post by Paul E. Surette
msExchMailboxGuid is an Octet String value and looks
something like
Post by Alex K. Angelopoulos [Server MVP]
Post by Paul E. Surette
this in ADSI Edit: 27 A3 4D 55 83 02 09 4C 9E F1 2C
26 06 17 25 01
Post by Alex K. Angelopoulos [Server MVP]
Post by Paul E. Surette
WScript.Echo "msExchMailboxGuid: " &
objUser.msExchMailboxGuid
Post by Alex K. Angelopoulos [Server MVP]
WScript.Echo Join(objUser.msExchMailboxGuid)
.
Tom Lavedas
2003-11-25 20:19:45 UTC
Permalink
Opps, that should have been ...

Function C8209toStr(body8209)
Dim i
ReDim aOut(UBound(body8209))
For i = 1 to UBound(body8209) + 1
aOut(i-1) = chr(ascb(midb(body8209,i,1)))
Next
C8209toStr = Join(aOut, "")
End Function

Tom Lavedas
===========
-----Original Message-----
That's an array of bytes, which is not directly
supported,
but some resourceful type (going my the moniker of lil
endian, I believe) worked out an algorithm that can
decode
these. It is painfully slow for very large byte arrays,
but is okay for shorter ones, like that encountered
here.
Here is my slight variation on the theme that makes it
quite a bit faster - suitable for arrays up to several
KB ...
' ...
wsh.echo C8209toStr(objUser.msExchMailboxGuid)
Function C8209toStr(body8209)
Dim aOut(UBound(body8209)), i
For i = 1 to UBound(body8209) + 1
aOut(i-1) = chr(ascb(midb(body8209,i,1)))
Next
C8209toStr = Join(aOut, "")
End Function
For large byte arrays the ADO (v2.5+) ByteStream is the
prefered solution - or maybe in all cases, if you're
comfortable with the ADO control, which I am not ;0)
Tom Lavedas
===========
-----Original Message-----
Thanks for the response.
Variable uses an Automation type not supported in
VBScript
When I do a WScript.Echo varType
(objUser.msExchMailboxGuid) I get a 8209 for
vbByte 17
vbArray 8192
8192 + 17 = 8209
Any other suggestions?
"Alex K. Angelopoulos [Server MVP]" <aka-at-mvps-dot-
org>
Post by Alex K. Angelopoulos [Server MVP]
Post by Paul E. Surette
Hello all,
The following code gives me a "VBScript runtime
error: Type mismatch"
Post by Alex K. Angelopoulos [Server MVP]
Post by Paul E. Surette
error when I try to display the msExchMailboxGuid.
The
Post by Alex K. Angelopoulos [Server MVP]
Post by Paul E. Surette
msExchMailboxGuid is an Octet String value and looks
something like
Post by Alex K. Angelopoulos [Server MVP]
Post by Paul E. Surette
this in ADSI Edit: 27 A3 4D 55 83 02 09 4C 9E F1 2C
26 06 17 25 01
Post by Alex K. Angelopoulos [Server MVP]
Post by Paul E. Surette
WScript.Echo "msExchMailboxGuid: " &
objUser.msExchMailboxGuid
Post by Alex K. Angelopoulos [Server MVP]
WScript.Echo Join(objUser.msExchMailboxGuid)
.
.
Paul E. Surette
2003-11-25 20:39:31 UTC
Permalink
Thanks for the code. I've modified it a touch to convert the results to
Hex, with a space between the results. works great. Having looked at the
code, it makes you step back, and smack your head and shake it a bit. I was
on the same track by ripping down the array, but I came up with 15 subsets
of ??????

I just needed to step through the array differently.

Thanks again!!!

-Paul
Post by Tom Lavedas
Opps, that should have been ...
Function C8209toStr(body8209)
Dim i
ReDim aOut(UBound(body8209))
For i = 1 to UBound(body8209) + 1
aOut(i-1) = chr(ascb(midb(body8209,i,1)))
Next
C8209toStr = Join(aOut, "")
End Function
Tom Lavedas
===========
-----Original Message-----
That's an array of bytes, which is not directly
supported,
but some resourceful type (going my the moniker of lil
endian, I believe) worked out an algorithm that can
decode
these. It is painfully slow for very large byte arrays,
but is okay for shorter ones, like that encountered
here.
Here is my slight variation on the theme that makes it
quite a bit faster - suitable for arrays up to several
KB ...
' ...
wsh.echo C8209toStr(objUser.msExchMailboxGuid)
Function C8209toStr(body8209)
Dim aOut(UBound(body8209)), i
For i = 1 to UBound(body8209) + 1
aOut(i-1) = chr(ascb(midb(body8209,i,1)))
Next
C8209toStr = Join(aOut, "")
End Function
For large byte arrays the ADO (v2.5+) ByteStream is the
prefered solution - or maybe in all cases, if you're
comfortable with the ADO control, which I am not ;0)
Tom Lavedas
===========
-----Original Message-----
Thanks for the response.
Variable uses an Automation type not supported in
VBScript
When I do a WScript.Echo varType
(objUser.msExchMailboxGuid) I get a 8209 for
vbByte 17
vbArray 8192
8192 + 17 = 8209
Any other suggestions?
"Alex K. Angelopoulos [Server MVP]" <aka-at-mvps-dot-
org>
Post by Alex K. Angelopoulos [Server MVP]
Post by Paul E. Surette
Hello all,
The following code gives me a "VBScript runtime
error: Type mismatch"
Post by Alex K. Angelopoulos [Server MVP]
Post by Paul E. Surette
error when I try to display the msExchMailboxGuid.
The
Post by Alex K. Angelopoulos [Server MVP]
Post by Paul E. Surette
msExchMailboxGuid is an Octet String value and looks
something like
Post by Alex K. Angelopoulos [Server MVP]
Post by Paul E. Surette
this in ADSI Edit: 27 A3 4D 55 83 02 09 4C 9E F1 2C
26 06 17 25 01
Post by Alex K. Angelopoulos [Server MVP]
Post by Paul E. Surette
WScript.Echo "msExchMailboxGuid: " &
objUser.msExchMailboxGuid
Post by Alex K. Angelopoulos [Server MVP]
WScript.Echo Join(objUser.msExchMailboxGuid)
.
.
Alex K. Angelopoulos [Server MVP]
2003-11-25 22:06:53 UTC
Permalink
Tom,

I haven't played with this lately, and I more or less punted my
implementation before. Do you have any clue what the ugly characters happen
to be yet?
Post by Tom Lavedas
Opps, that should have been ...
Function C8209toStr(body8209)
Dim i
ReDim aOut(UBound(body8209))
For i = 1 to UBound(body8209) + 1
aOut(i-1) = chr(ascb(midb(body8209,i,1)))
Next
C8209toStr = Join(aOut, "")
End Function
Tom Lavedas
===========
-----Original Message-----
That's an array of bytes, which is not directly supported,
but some resourceful type (going my the moniker of lil
endian, I believe) worked out an algorithm that can decode
these. It is painfully slow for very large byte arrays,
but is okay for shorter ones, like that encountered here.
Here is my slight variation on the theme that makes it
quite a bit faster - suitable for arrays up to several
KB ...
' ...
wsh.echo C8209toStr(objUser.msExchMailboxGuid)
Function C8209toStr(body8209)
Dim aOut(UBound(body8209)), i
For i = 1 to UBound(body8209) + 1
aOut(i-1) = chr(ascb(midb(body8209,i,1)))
Next
C8209toStr = Join(aOut, "")
End Function
For large byte arrays the ADO (v2.5+) ByteStream is the
prefered solution - or maybe in all cases, if you're
comfortable with the ADO control, which I am not ;0)
Tom Lavedas
===========
-----Original Message-----
Thanks for the response.
Variable uses an Automation type not supported in VBScript
When I do a WScript.Echo varType
(objUser.msExchMailboxGuid) I get a 8209 for
vbByte 17
vbArray 8192
8192 + 17 = 8209
Any other suggestions?
"Alex K. Angelopoulos [Server MVP]" <aka-at-mvps-dot- org> wrote in
Post by Alex K. Angelopoulos [Server MVP]
Post by Paul E. Surette
Hello all,
The following code gives me a "VBScript runtime error: Type
mismatch" error when I try to display the msExchMailboxGuid. The
msExchMailboxGuid is an Octet String value and looks something like
this in ADSI Edit: 27 A3 4D 55 83 02 09 4C 9E F1 2C 26 06 17 25 01
WScript.Echo "msExchMailboxGuid: " & objUser.msExchMailboxGuid
WScript.Echo Join(objUser.msExchMailboxGuid)
.
.
Tom Lavedas
2003-11-26 13:26:02 UTC
Permalink
Are you refering to this thread or the one over in .WSH where
Wzzip.exe was being blocked by the stuff being sent to the StdErr?

If it relates to this thread, I never ran the original code. I don't
use ADSI, so am unfamiliar with it. I just conveyed what I knew about
processing byte arrays.

If it's about the other thread to which we have both contributed, I
defer to that thread for my response.

Tom Lavedas
===========
Post by Alex K. Angelopoulos [Server MVP]
Tom,
I haven't played with this lately, and I more or less punted my
implementation before. Do you have any clue what the ugly characters happen
to be yet?
Post by Tom Lavedas
Opps, that should have been ...
Alex K. Angelopoulos [Server MVP]
2003-11-26 18:18:35 UTC
Permalink
Oops! Yes, wrong thread. :)
Post by Tom Lavedas
If it's about the other thread to which we have both contributed, I
defer to that thread for my response.
Loading...