Page 1 of 2 12>
Topic Options
#128285 - 2004-10-22 12:02 PM IDispatch pointers not allowed in expressions!
jan Offline
Getting the hang of it

Registered: 2004-07-07
Posts: 66
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

Top
#128286 - 2004-10-22 12:17 PM Re: IDispatch pointers not allowed in expressions!
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
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;")
_________________________



Top
#128287 - 2004-10-22 02:19 PM Re: IDispatch pointers not allowed in expressions!
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
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.
_________________________
!

download KiXnet

Top
#128288 - 2004-10-22 03:54 PM Re: IDispatch pointers not allowed in expressions!
jan Offline
Getting the hang of it

Registered: 2004-07-07
Posts: 66
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

Top
#128289 - 2004-10-22 04:02 PM Re: IDispatch pointers not allowed in expressions!
jan Offline
Getting the hang of it

Registered: 2004-07-07
Posts: 66
Btw,

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

Jan

Top
#128290 - 2004-10-22 04:44 PM Re: IDispatch pointers not allowed in expressions!
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
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.
_________________________
!

download KiXnet

Top
#128291 - 2004-10-22 06:01 PM Re: IDispatch pointers not allowed in expressions
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
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;")


Top
#128292 - 2004-10-25 11:03 AM Re: IDispatch pointers not allowed in expressions
jan Offline
Getting the hang of it

Registered: 2004-07-07
Posts: 66
Yes I tried but it didn't fixed my problem
Top
#128293 - 2004-10-25 11:05 AM Re: IDispatch pointers not allowed in expressions!
jan Offline
Getting the hang of it

Registered: 2004-07-07
Posts: 66
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

Top
#128294 - 2004-10-25 01:46 PM Re: IDispatch pointers not allowed in expressions!
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
IIRC there was an IDispatch problem with that version.
What happens if you run this with V. 4.22 ?
_________________________



Top
#128295 - 2004-10-25 02:07 PM Re: IDispatch pointers not allowed in expressions
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
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


Top
#128296 - 2004-10-25 02:11 PM Re: IDispatch pointers not allowed in expressions!
jan Offline
Getting the hang of it

Registered: 2004-07-07
Posts: 66
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

Top
#128297 - 2004-10-25 02:16 PM Re: IDispatch pointers not allowed in expressions!
maciep Offline
Korg Regular
*****

Registered: 2002-06-14
Posts: 947
Loc: Pittsburgh
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

_________________________
Eric

Top
#128298 - 2004-10-25 02:25 PM Re: IDispatch pointers not allowed in expressions
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
I guess Shawn wins the Goose this time
_________________________



Top
#128299 - 2004-10-25 02:25 PM Re: IDispatch pointers not allowed in expressions!
jan Offline
Getting the hang of it

Registered: 2004-07-07
Posts: 66
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?

Top
#128300 - 2004-10-25 02:30 PM Re: IDispatch pointers not allowed in expressions
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
Me thinks you have a corrupt kix32.exe, try re-downloading the latest and try again.

Did I hear something about a goose ?

Top
#128301 - 2004-10-25 02:43 PM Re: IDispatch pointers not allowed in expressions
jan Offline
Getting the hang of it

Registered: 2004-07-07
Posts: 66
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"

Top
#128302 - 2004-10-25 02:47 PM Re: IDispatch pointers not allowed in expressions
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
Either this (not) or he runs Norton Antivirus

_________________________



Top
#128303 - 2004-10-25 02:53 PM Re: IDispatch pointers not allowed in expressions
jan Offline
Getting the hang of it

Registered: 2004-07-07
Posts: 66
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

Top
#128304 - 2004-10-25 03:09 PM Re: IDispatch pointers not allowed in expressions
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
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


Top
Page 1 of 2 12>


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

Who's Online
0 registered and 436 anonymous users online.
Newest Members
SERoyalty, mytar, Gabriel, Alex_Evos, Dansen
17869 Registered Users

Generated in 0.173 seconds in which 0.09 seconds were spent on a total of 12 queries. Zlib compression enabled.

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