View Full Version : PHP and DCOM

11-12-2007, 12:30 PM
I have the following code;

$objMetaFrameFarm = new COM("MetaFrameCOM.MetaFrameFarm");

$objTheSessions = $objMetaFrameFarm->Sessions;

print $objMetaFrameFarm->FarmName;
$objMetaFrameServers = $objMetaFrameFarm->Servers;


foreach($objMetaFrameServers as $objMetaFrameServer)
echo $objMetaFrameServer->ServerName;
catch (com_exception $x)
print $x . "\n";


If I run it as is I get a http 500 error if I comment out the foreach the code seems to run fine. If I then add
$count = $objTheSessions->Count; inside the try it throws the following useful exception;

exception 'com_exception' with message 'Source: Unknown
Description: Unknown' in C:\Inetpub\wwwroot\Citrix_test_again.php:19 Stack trace: #0 C:\Inetpub\wwwroot\Citrix_test_again.php(19): unknown() #1 {main}

Count is a property of the Sessions object.
print $objMetaFrameFarm->FarmName; works correctly and is output to the browser.

I was under the impression that foreach allows you to traverse a collection like for each in vb but this does not seem to be the case the sessions object does implement a _NewEnum property which returns an enumerator (ienumvariant) object for the collection I'm having some difficulty with the syntax though......

Does anyone have any suggestions? Thanks.