jan
(Getting the hang of it)
2004-10-22 12:02 PM
IDispatch pointers not allowed in expressions!

Hi,

Can see several have had problems with IDispatch pointers not allowed in expressions! But I've been unable to find any solutions. Here's my code:

FUNCTION mailbox($getou)
$mailbox=GETOBJECT("LDAP://$getou")
? "getobj @serror"
? "User Information:"
? "Display Name: " $mailbox.get("cn")
? "Given Name: " $mailbox.get("givenname")
? "Last Name: " $mailbox.get("sn")
? "Alias: " $mailbox.get("uid")

ENDFUNCTION


FUNCTION getOU($userName)

DIM $dn,$objRootDSE,$strDomain
DIM $objConnection,$objCommand
DIM $objRecordSet
$getOU = "Not Found"
$objRootDSE = GETOBJECT("LDAP://RootDSE")
$strDomain = $objRootDSE.Get("DefaultNamingContext")

$objConnection = CREATEOBJECT("ADODB.Connection")
$objConnection.Open ("Provider=ADsDSOObject;")
$objCommand = CREATEOBJECT("ADODB.Command")
$objCommand.ActiveConnection = $objConnection
$objCommand.CommandText =
"<LDAP://" + $strDomain + ">;((saMAccountName=" + $userName + "))" +
";distinguishedName,name;subtree"

$objRecordSet = $objCommand.Execute

WHILE Not $objRecordSet.EOF
$dn = $objRecordSet.Fields("distinguishedName").Value
$getOU = $dn
$objRecordSet.MoveNext
LOOP

mailbox($getou)

ENDFUNCTION


BREAK on

? "Enter username: " GETS $username

getOU($username)

Hope someone can help me


JochenAdministrator
(KiX Supporter)
2004-10-22 12:17 PM
Re: IDispatch pointers not allowed in expressions!

this is normally caused by 'unassigned' COM method calls
Can't test this currently but try to assign a dummy var to some of your calls.

ie. $nul = $objConnection.Open ("Provider=ADsDSOObject;")


LonkeroAdministrator
(KiX Master Guru)
2004-10-22 02:19 PM
Re: IDispatch pointers not allowed in expressions!

well, you should help us help you by telling us the whole error text.

the idispatch is normally indeed caused by lazy or careless coding that feeds objects to the console.


jan
(Getting the hang of it)
2004-10-22 03:54 PM
Re: IDispatch pointers not allowed in expressions!

That's the hole error text I have given you. It's stops with last line in the function mailbox, but if I comment the line, it just moves up a line. I've tried to comment everything except the first "$mailbox=GETOBJECT("LDAP://$getou")" and I stille got the error

Hope this answers your question


jan
(Getting the hang of it)
2004-10-22 04:02 PM
Re: IDispatch pointers not allowed in expressions!

Btw,

" "getobj @serror"" says it's successfully

Jan


LonkeroAdministrator
(KiX Master Guru)
2004-10-22 04:44 PM
Re: IDispatch pointers not allowed in expressions!

what version of kixtart you are using?
I know that if I get error in my script, the error says on what line that happens.


ShawnAdministrator
(KiX Supporter)
2004-10-22 06:01 PM
Re: IDispatch pointers not allowed in expressions

Did you try like Jochen said, suppressing the return obj in this line here. Think this would indeed cause some trouble:

$nul = $objConnection.Open ("Provider=ADsDSOObject;")



jan
(Getting the hang of it)
2004-10-25 11:03 AM
Re: IDispatch pointers not allowed in expressions

Yes I tried but it didn't fixed my problem

jan
(Getting the hang of it)
2004-10-25 11:05 AM
Re: IDispatch pointers not allowed in expressions!

I'm using ver 4.21.

It does say which line the problem is, but if I comment that line the problem move 1 line up until I have comment every line then it does give any errors


JochenAdministrator
(KiX Supporter)
2004-10-25 01:46 PM
Re: IDispatch pointers not allowed in expressions!

IIRC there was an IDispatch problem with that version.
What happens if you run this with V. 4.22 ?


ShawnAdministrator
(KiX Supporter)
2004-10-25 02:07 PM
Re: IDispatch pointers not allowed in expressions

hmmm, think it might be this:

In your GetOU function, at the end, your making a call to this function:

mailbox($getou)

If you look, you will see that this function returns an object:

$mailbox=GETOBJECT("LDAP://$getou")

And you don't "silence" that return value in getou(), like this:

$= mailbox($getou)

Try that.

-Shawn



jan
(Getting the hang of it)
2004-10-25 02:11 PM
Re: IDispatch pointers not allowed in expressions!

Hi,

If I run 4.22 I get this error:
In-page IO exception occurred.
This type of exception is thrown by the Windows Memory Manager when it fails
to (re)read code from the KiXtart executable.
Common causes for this exception include:
-running WKIX32 from a batchfile without using START /w
-forced redirection of the network drive from which KiXtart was started
-severe network errors/latency
-faulty anti-virus software

If I use wkix32 I get the same "IDispatch pointers not allowed in expressions!" error in a window


maciep
(Korg Regular)
2004-10-25 02:16 PM
Re: IDispatch pointers not allowed in expressions!

Try this mailbox() function. Right now you are assigning the return value of the mailbox function to that object. I just changed it to be a local var. I think this what you meant to do.

Code:

FUNCTION mailbox($getou)
dim $objMailbox
$objMailbox=GETOBJECT("LDAP://$getou")
? "Mailbox Information for $username:"
? "User Information:"
? "Display Name: " $objMailbox.get("cn")
? "Given Name: " $objMailbox.get("givenname")
? "Last Name: " $objMailbox.get("sn")
? "Alias: " $objMailbox.get("uid")
? "Mailbox Information:"
? "Primary SMTP: " $objMailbox.get("mail")
? "X.400 Address: " $objMailbox.get("textencodedoraddress")
? "Home MTA: " $objMailbox.get("home-mta")
? "Home MDA: " $objMailbox.get("home-mda")

ENDFUNCTION



JochenAdministrator
(KiX Supporter)
2004-10-25 02:25 PM
Re: IDispatch pointers not allowed in expressions

I guess Shawn wins the Goose this time

jan
(Getting the hang of it)
2004-10-25 02:25 PM
Re: IDispatch pointers not allowed in expressions!

Hi,

I get the same error :-(

Now Itried to run it in debug mode and to my big surprise the gives the error when doing DIM.....:
DIM $dn,$objRootDSE,$strDomain
DIM $objConnection,$objCommand

When it DIM's the secondline I get the error:
In-page IO exception occurred.
This type of exception is thrown by the Windows Memory Manager when it fails
to (re)read code from the KiXtart executable.
Common causes for this exception include:
-running WKIX32 from a batchfile without using START /w
-forced redirection of the network drive from which KiXtart was started
-severe network errors/latency
-faulty anti-virus software

If I use Wkix32 it works

What is the different between kix32 and wkix32?


ShawnAdministrator
(KiX Supporter)
2004-10-25 02:30 PM
Re: IDispatch pointers not allowed in expressions

Me thinks you have a corrupt kix32.exe, try re-downloading the latest and try again.

Did I hear something about a goose ?


jan
(Getting the hang of it)
2004-10-25 02:43 PM
Re: IDispatch pointers not allowed in expressions

I did a re-download and I got the same problem. Tried to download the latest devel. build, but that's a dead link

It seems that it doesn't likes my DIM's in the function "getOU" and that's a new problem

"Help me! Obi-Wan-Kenobi"


JochenAdministrator
(KiX Supporter)
2004-10-25 02:47 PM
Re: IDispatch pointers not allowed in expressions

Either this (not) or he runs Norton Antivirus



jan
(Getting the hang of it)
2004-10-25 02:53 PM
Re: IDispatch pointers not allowed in expressions

It's WORKING!!!!!

I just rebooted my pc. Must be something with my McAfee that did something crappy because it was stopped working and after I rebooted it worked again and now I could run the scripts

Thanks a lot for your help. You are all my heros


Richard H.Administrator
(KiX Supporter)
2004-10-25 03:09 PM
Re: IDispatch pointers not allowed in expressions

Cannot test here (don't have the infrastructure), but try this:
Code:
Break ON
$=SetOption("Explicit","ON")
$=SetOption("WrapAtEOL","ON")

Dim $sUser
Dim $oMailBox

"Enter username: " GetS $sUser
$oMailBox=udfGetMailBox(udfGetOU($sUser))
If @ERROR udfError("while attempting to get mailbox") EndIf
Exit 0



Function udfGetMailbox($sOU)
If Not $sOU Exit @ERROR EndIf
$mailbox=GetObject("LDAP://"+$sOU)
If @ERROR udfError("getting mailbox") Exit @ERROR EndIf
EndFunction

Function udfGetOU($sUserName)
Dim $dn,$objRootDSE,$strDomain
Dim $objConnection,$objCommand
Dim $objRecordSet

$udfGetOU=""

$objRootDSE = GetObject("LDAP://RootDSE")
If @ERROR udfError("getting RootDSE") Exit @ERROR EndIf
$strDomain = $objRootDSE.Get("DefaultNamingContext")

$objConnection = CreateObject("ADODB.Connection")
If @ERROR udfError("creating ADODB connection") Exit @ERROR EndIf
$objConnection.Open("Provider=ADsDSOObject;")
If @ERROR udfError("opening ADODB provider") Exit @ERROR EndIf
$objCommand = CREATEOBJECT("ADODB.Command")
If @ERROR udfError("creating ADODB command") Exit @ERROR EndIf
$objCommand.ActiveConnection = $objConnection
$objCommand.CommandText =
"<LDAP://"
+$strDomain
+">;((saMAccountName="
+$sUserName
+"))"
+";distinguishedName,name;subtree"

$objRecordSet = $objCommand.Execute

While Not $objRecordSet.EOF
$dn = $objRecordSet.Fields("distinguishedName").Value
$udfGetOU = $dn
$objRecordSet.MoveNext
Loop
EndFunction

Function udfError($s)
"ERROR: While "+$s+@CRLF
"Reason: ["+@ERROR+"] "+@SERROR+@CRLF
Exit @ERROR
EndFunction



ShawnAdministrator
(KiX Supporter)
2004-10-25 03:10 PM
Re: IDispatch pointers not allowed in expressions

Well, I ran your script here (granted, i am using the latest 4.50 alpha build) but got this as output:

E:\>kix32 t

Enter username: shawn.tassie

getobj The operation completed successfully.
User Information:
Display Name: Shawn.Tassie
Given Name: Shawn
Last Name: Tassie
Alias: CN=Shawn.Tassie,OU=BCCS Dev Users,OU=Bell Users,OU=Bell,OU=Business Units
,DC=belldev,DC=***,DC=***,DC=**

E:\>



ShawnAdministrator
(KiX Supporter)
2004-10-25 03:15 PM
Re: IDispatch pointers not allowed in expressions

Its working! Great to hear. Good co-operative effort by all involved.

Still want the goose though. Can somebody please give me the goose ? ;0)


JochenAdministrator
(KiX Supporter)
2004-10-25 03:15 PM
Re: IDispatch pointers not allowed in expressions

*sssht

he said it's working now


Les
(KiX Master)
2004-10-25 03:28 PM
Re: IDispatch pointers not allowed in expressions

First sheep, and now goose...

JochenAdministrator
(KiX Supporter)
2004-10-25 03:49 PM
Re: IDispatch pointers not allowed in expressions

baaaaaaah

LonkeroAdministrator
(KiX Master Guru)
2004-10-26 09:23 AM
Re: IDispatch pointers not allowed in expressions

weirdly enough, I got this in page [censored] today too!
and if that wasn't enough, on not crashing run kixtart errors from registry write as "system can't find the file specified"

doh.


Arend_
(MM club member)
2007-11-19 02:01 PM
Re: IDispatch pointers not allowed in expressions

Just for the fun of dragging up an old subject I get the same error using ADODB.Connection

Here's my code
 Code:
$cmd = 'Driver={MySQL ODBC 3.51 Driver};Option=16387;Server=127.0.0.1;uid=admin;pwd=pass1;'
$cn = CreateObject("ADODB.Connection")
$cn.Open($cmd)
? $cn.State
$cn.Execute("DROP DATABASE test")
$cn.Close
$cn = ""

If I use $=$cn.Execute("DROP DATABASE test")
The error is suppressed, however I feel that this error shouln't come up in the first place. (using kix 4.60)


Arend_
(MM club member)
2007-11-20 07:53 PM
Re: IDispatch pointers not allowed in expressions

Oh yeah I forgot: