Bug #74994 [NEW]: COM Win32_PingStatus error
| From: | benjamin dot versini at gmail dot com | Date: | Thu, 27 Jul 2017 08:16:18 +0000 |
| Subject: | Bug #74994 [NEW]: COM Win32_PingStatus error | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-210364@lists.php.net to get a copy of this message | ||
From: benjamin dot versini at gmail dot com
Operating system: Windows 2016 Standard
PHP version: 7.1.7
Package: COM related
Bug Type: Bug
Bug description:COM Win32_PingStatus error
Description:
------------
Hi,
I use the COM object of PHP to access to WMI Win32_PingStatus for create
a remote ping. It's impossible to obtain the result of my request:
My Error:
com_exception
Unable to lookup `statuscode': Unknown Name.
Test script:
---------------
My Class:
class Windows
{
protected $servers;
protected $username;
protected $password;
public function __construct($servers, $username, $password)
{
$this->servers = $servers;
$this->username = $username;
$this->password = $password;
}
protected function services($command)
{
$services = (new \COM
("WbemScripting.SWbemLocator"))->ConnectServer($this->servers, $command,
$this->username, $this->password);
$services->Security_->AuthenticationLevel = 3;
$services->Security_->ImpersonationLevel = 3;
return $services;
}
public function getHosts()
{
return $this->services('root\\cimv2')
->ExecQuery('Select * from Win32_ComputerSystem');
}
public function GetPing($srv)
{
var_dump($srv);
return $this->services('root\\cimv2')
->ExecQuery('select * from Win32_Pingstatus where
Address='.$srv.'');
}
}
And my View:
$servername = '10.54.1.5';
$vmadress = new \Windows($servername,
'Ceicom-Cloud\Administrateur', 'Ceicom3333');
$pings = $vmadress->getPing('10.16.0.1');
foreach ($pings->statuscode as $ping)
var_dump($ping);
I have tested my class with my function getHosts and it's Ok !
Expected result:
----------------
If i user the PowerShell for Win32_PingStatus (With the same code) i
have the return of statuscode...
--
Edit bug report at https://bugs.php.net/bug.php?id=74994&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=74994&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=74994&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=74994&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=74994&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=74994&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=74994&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=74994&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=74994&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=74994&r=support
Expected behavior: https://bugs.php.net/fix.php?id=74994&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=74994&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=74994&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=74994&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=74994&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=74994&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=74994&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=74994&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=74994&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=74994&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=74994&r=mysqlcfg