DCOM in PHP

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

psmshankar
Forum Commoner
Posts: 96
Joined: Tue Aug 06, 2002 4:25 am
Location: India

DCOM in PHP

Post 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
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

have you enabled com.allow_dcom in php.ini?
psmshankar
Forum Commoner
Posts: 96
Joined: Tue Aug 06, 2002 4:25 am
Location: India

Post by psmshankar »

Hi
There is no such thing in my ini file...
i am using php 4.0

Shankar
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post 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
psmshankar
Forum Commoner
Posts: 96
Joined: Tue Aug 06, 2002 4:25 am
Location: India

Post by psmshankar »

so does it mean that in PHP version 4.0 i cannot use DCOM????
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post 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.
psmshankar
Forum Commoner
Posts: 96
Joined: Tue Aug 06, 2002 4:25 am
Location: India

Post by psmshankar »

yeah....i tried this...but doesn't seems to work???
i am afraid if it supports version 4????
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post 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.
psmshankar
Forum Commoner
Posts: 96
Joined: Tue Aug 06, 2002 4:25 am
Location: India

Post 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?
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post 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
psmshankar
Forum Commoner
Posts: 96
Joined: Tue Aug 06, 2002 4:25 am
Location: India

Post 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????
User avatar
mydimension
Moderator
Posts: 531
Joined: Tue Apr 23, 2002 6:00 pm
Location: Lowell, MA USA
Contact:

Post 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.
psmshankar
Forum Commoner
Posts: 96
Joined: Tue Aug 06, 2002 4:25 am
Location: India

Post 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
psmshankar
Forum Commoner
Posts: 96
Joined: Tue Aug 06, 2002 4:25 am
Location: India

Post 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
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post 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?
Post Reply