Joeri Sebrechts
Joeri Sebrechts

Reputation: 11136

Query IIS FastCGI settings from PHP

I am trying to programmatically query the FastCGI settings configured in IIS through PHP's COM API using WMI.

Using WMI CIM Studio I can see there is a FastCgiSection class which has a FastCgi member array that contains exactly the settings I want (specifically ActivityTimeout and RequestTimeout): http://msdn.microsoft.com/en-us/library/bb422421(v=vs.90).aspx

However, any attempt at querying this so far has not succeeded. The examples of querying Win32_Processor and so on that you can find online work fine, but translating that into a query of the FastCgiSection isn't working out.

So far I have this, which isn't outputting anything:

$wmi = new \COM('winmgmts:{impersonationLevel=Impersonate}//./root/WebAdministration');
$arrData = $wmi->ExecQuery("SELECT * FROM FastCgiSection");
foreach ($arrData as $obj) {
   echo "has result";
}

How do I access this API through WMI in PHP?

Upvotes: 4

Views: 294

Answers (2)

CedX
CedX

Reputation: 3977

Your query returns FastCgiSection objects, while the FastCGI application settings are stored in FastCgiApplicationElement class.

Your code doesn't access FastCgi member, only the objects returned by the WMI query. You need another loop over the FastCgi property in order to get what you want:

$wmi=new COM('winmgmts:{impersonationLevel=Impersonate}//./root/WebAdministration');
foreach($wmi->ExecQuery('SELECT * FROM FastCgiSection') as $section) {
  foreach($section->FastCgi as $application) {
    echo $application->ActivityTimeout, PHP_EOL;
    echo $application->RequestTimeout, PHP_EOL;
  }
}

Note that, in order for this code to work, you'll need to:

Upvotes: 2

Jonathon Hibbard
Jonathon Hibbard

Reputation: 1546

Just in case you haven't already seen it, here is a pretty good link going into a lot of detail about doing very close to the same thing you're trying: http://www.sitepoint.com/php-wmi-dig-deep-windows-php/

One thing that I'd say to do ( if you haven't already ) is to check and verify the following is enabled in your php.ini: extension=php_com_dotnet.dll

Upvotes: 3

Related Questions