Hudzilla.org - the homepage of Paul Hudson
Contents > Java and COM > Getting started with COM Wish List | Report Bug | About Me ]

14.1.5     DCOM

This is NOT the latest copy of this book; click here for the latest version.

An extension to COM is Distributed COM (DCOM), Microsoft's competitor to the Common Object Request Broker Architecture (CORBA). DCOM allows you, once the correct permissions have been worked out, to create and use COM objects on other machines, as if they were local. As DCOM is just COM done remotely, it is very easy to make use of, but first you need to make sure you have DCOM support enabled in your php.ini file.

If you used the default php.ini, you probably have DCOM support disabled. Open up your php.ini file, search for "com.allow_dcom", and make sure the line is not commented out with a semi-colon, and has its value set to true. Once this is done, restart your web server so that it reloads the modified php.ini file, and you are all set to use COM.

To create a remote COM object, all you need to do is change your call to the COM constructor. Right now we just pass in the name of the object to create, but to create a remote object, you need to pass in the name of the server as the second parameter. Otherwise, everything is the same - once the COM object is created, it does not matter whether it is local or remote, which is one of the advantages of the COM system.

So, to create a WScript.Shell component on server "moggieboo", you would use code like this:

$shell = new COM("WScript.Shell", "moggieboo");

Note that DCOM has very strict security procedures behind it, because it is obviously quite dangerous to allow remote users to execute arbitrary code on a local machine. You will need to refer to your system administrator / favourite Windows technical site for information on DCOM permissions, however a good place to start is in the "dcomcnfg" program, as that allows you to enable DCOM permissions for various users.







<< 14.1.4 The possibilities of COM   14.1.6 Microsoft .NET >>
Table of Contents
Want to see this stuff in print? PHP in a Nutshell takes the core topics covered here, adds in thousands of edits from the editorial team and myself, and combines them to make an unbeatable reference for PHP programmers at all levels.



My latest book has hundreds more tips on how to use PHP, Apache, and MySQL, plus Perl, Python, shell scripts, performance tuning, and more!



Top-right shadow
 
Bottom-left shadow Bottom shadow

Comments from other readers
A PHP User - 06 Sep 2008

Is it possible to connect to a server through TCP-IP?



Add comment
Please note that by posting a comment here you are committing it to the public domain. This is important so that others can make use of your code themselves, and also so that I can incorporate helpful notes directly into the main text. Comments are limited to 2000 characters in length.

If you are reporting an error in the content, please tell me directly.

Your name/email address:
Your comment:
 
Now, in order to verify that you're a real person, please answer this simple question: what is zero plus nine?
The answer is:
(please write in
numbers, eg 19)


Top-right shadow
 
Bottom-left shadow Bottom shadow