Page 1 of 2

DCOM in PHP

Posted: Tue Oct 01, 2002 1:56 am
by psmshankar
Hi all,

I am using PHP 4.0 running under Apache on Win'98 box.
I have created a COM object and has to instantiate this and make use of this COM object from another machine also running PHP 4.0/win'98.

the syntax i used is:

$objDevice = new COM("SMSServer.clsDevice","10.100.120.67")or die("Unable to instantiate");

but it always shows unable to instantiate??

I have registered the COM object in the server 10.100.120.67
so from server A i am instantiating a COM object in server B(10.100.120.67)

Where i am wrong...from the local machine i am able to do..that is just COM...but when i used DCOM it says unable to instantiate??

Am i missing out anything
pls help me out.

Thanks
Shankar

Posted: Tue Oct 01, 2002 9:45 am
by volka
have you enabled com.allow_dcom in php.ini?

Posted: Tue Oct 01, 2002 9:57 am
by psmshankar
Hi
There is no such thing in my ini file...
i am using php 4.0

Shankar

Posted: Tue Oct 01, 2002 9:59 am
by volka
not beeing in your php.ini yet doesn't mean you can't add it ;)
http://www.php.net/manual/en/class.com.php

Posted: Tue Oct 01, 2002 10:30 am
by psmshankar
so does it mean that in PHP version 4.0 i cannot use DCOM????

Posted: Tue Oct 01, 2002 10:36 am
by volka
just add the line

Code: Select all

com.allow_dcom=On
to your php.ini and take a look. I don't know it - the manual is kind of preliminary.

Posted: Tue Oct 01, 2002 10:50 am
by psmshankar
yeah....i tried this...but doesn't seems to work???
i am afraid if it supports version 4????

Posted: Tue Oct 01, 2002 11:01 am
by volka
in the source code for php 4.2.3 there is a call to CoCreateInstanceEx in <php>/ext/COM/COM.c indicating DCOM support.

Posted: Tue Oct 01, 2002 11:08 am
by psmshankar
so it means 4.0 doesn't support is it...???
so i need to go for version atleast 4.1??? am i right???
can i upgrade to 4.1 or so version???
if i upgrade will my programs/ setting will be affected in anyway???
so just i can get whatever version and upgrade is it?

Posted: Tue Oct 01, 2002 6:32 pm
by volka
I was only speaking of php 4.2.3.
<?php phpinfo(); ?> should tell wether there is (d)com-support or not. mine tells me
com
Directive Local Value Master Value
com.allow_dcom Off Off
com.autoregister_casesensitive On On
com.autoregister_typelib Off Off
com.autoregister_verbose Off Off
com.typelib_file no value no value
and I have not a single (active) config-line for com in my php.ini

If it is possible for you to upgrade and you think you can manage it, do it.

Is your component accessible by DCOM?
If uncertain search for a dcomcnfg tutorial i.e. with google

Posted: Tue Oct 01, 2002 10:43 pm
by psmshankar
Hi,

I have only this thing when i run phpinfo()
com
Directive Local Value Master Value
allow_dcom Off Off
typelib_file no value no value

and when i checked in my php.ini file there is no directive for COM...???
so from where this phpinfo() function is getting and displaying this COM directive????

Posted: Tue Oct 01, 2002 10:49 pm
by mydimension
it shows that because that is the default setting hardcoded into the php source code. using php.ini you can override that setting by following the directions posted above. just make sure to restart the web server or the change to php.ini will not take effect.

Posted: Tue Oct 01, 2002 10:57 pm
by psmshankar
hi mydimension

so can i put the following in my php.ini??

[com]

; path to a file containing GUIDs, IIDs or filenames of files with TypeLibs

com.typelib_file=

allow Distributed-COM calls

com.allow_dcom=true

; autoregister constants of a components typlib on com_load()

com.autoregister_typelib=true

; register constants casesensitive

;com.autoregister_casesensitive=false

; show warnings on duplicate constat registrations

com.autoregister_verbose=true
I will add the above at the end?? then i will restart ?? is it ok..

Shankar

Posted: Wed Oct 02, 2002 2:41 am
by psmshankar
Hi,

I tried by putting the above piece of code in php.ini file..
but it doesn't seems to work...

following is the content i added in php.ini file
--------------------------------------------------
[com]

; path to a file containing GUIDs, IIDs or filenames of files with TypeLibs

com.typelib_file=

allow Distributed-COM calls

com.allow_dcom=true

; autoregister constants of a components typlib on com_load()

com.autoregister_typelib=true

; register constants casesensitive

com.autoregister_casesensitive=false

; show warnings on duplicate constat registrations

com.autoregister_verbose=true
---------------------------------------------------

following is the piece of code instantiating the COM object in another machine

//************************************************************// Instantiating clsDevice class to check the device status...
//************************************************************
$objDevice = new COM("SMSServer.clsDevice","10.100.120.67") or die("Unable to instantiate SMS Server: clsDevice component");
$objDevice->CheckDeviceStatus();
$DevStatus = $objDevice->DeviceStatus;

it always says 'Unable to instantiate'.....

ofcourse this COM object is registered on the server in which it resides(10.100.120.67) and also i regitered the same in server A where the aboce piece of php code is running...

pls help me to sort it out as i have to do this quickly...

Thanks
Shankar

Posted: Wed Oct 02, 2002 7:54 am
by volka
if new COM fails it should produce an zend_error that can be found in the server-log.
But as mentioned I think the whole COM-module (or at least the documention) is preliminary. I.e. did you know that server_name can be an array (don't know if it can be in php-ver < 4.2.3).
I found in the sources
...
else if (Z_TYPE_P(server_name) == IS_ARRAY) {...
  • if it is an array it fetches the entries
  • server_name["Username"]
  • server_name["Domain"]
  • server_name["Password"]
  • server_name["Flags"]
if you do not set these values it tries to perform the request with default values. This means, that the properties of the current process are used. Probably from your apache/IIS/<whatever webserver you use>-process.
'Under' which account does your webserver run? can you login with these (exactly the same) setting on the other server (that 'holds' the component)? If so, can you create a new instance of your component with this account?
And once again: have you checked dcomcnfg?