|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2003-10-06 09:26 UTC] david dot nicholls at camden dot gov dot uk
Description: ------------ Following on from bug 25732 I am trying PHP5-dev from CVS Code that worked previously under 4.3.3 now fails silently error_reporting = E_ALL is set Reproduce code: --------------- $acctDomain = "Camden"; echo "Making COM connection using ADSI\n\r"; $acctStr = "WinNT://".$acctDomain; echo "$acctStr\n\r"; $comUsers = new COM($acctStr); echo "new COM Sucessful"; Expected result: ---------------- 'new COM Sucessful' to be printed at console or an error code Actual result: -------------- Nothing, just brings back command promt C:\Inetpub\wwwroot\ntadmin>php comtest.php Content-type: text/html X-Powered-By: PHP/5.0.0b2-dev Making COM connection using ADSI WinNT://Camden C:\Inetpub\wwwroot\ntadmin> PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 08:00:01 2025 UTC |
Try it with exception handlers: try { $comUsers = new COM($acctStr); } catch (exception $e) { print_r($e); }Looks like PHP is messing up valid syntax exception Object ( [message:protected] => Unknown exception [string:private] => [code:protected] => 0 [file:protected] => C:\Inetpub\wwwroot\ntadmin\comtest.php [line:protected] => 15 [trace:private] => Array ( ) [message] => Failed to create COM object `WinNT://Camden': Invalid syntax [file] => C:\Inetpub\wwwroot\ntadmin\comtest.php [line] => 15 )The bug fix worked thanks and I can now do the instatitaion. However there are issues at the next stage :( This works under 4 and not 5 I suspect "while($obj = $comUsers->Next())" (dont know how to put in the exception handling code there) <?php $acctDomain = "Camden"; echo "Making COM connection using ADSI\n\r"; $acctStr = "WinNT://".$acctDomain; echo "$acctStr\n\r"; $comUsers = new COM($acctStr); echo "Bound"; while($obj = $comUsers->Next()) { $uClass = $obj->Class; $uName = $obj->Name; echo "$uName \t $uClass \n\r"; } ?>Put the try { } catch () stuff around the whole of your script and lets see what's going wrong. (Yes, PHP should at least tell you about the uncaught exception; that appears to be another bug)Its one of the usefule errors :) C:\Inetpub\wwwroot\ntadmin>php comtest.php Content-type: text/html X-Powered-By: PHP/5.0.0b2-dev Making COM connection using ADSI WinNT://Camden Boundexception Object ( [message:protected] => Unknown exception [string:private] => [code:protected] => 0 [file:protected] => C:\Inetpub\wwwroot\ntadmin\comtest.php [line:protected] => 12 [trace:private] => Array ( ) [message] => <b>Source:</b> Active Directory<br/><b>Description:</b> Unspecified error [file] => C:\Inetpub\wwwroot\ntadmin\comtest.php [line] => 12 ) C:\Inetpub\wwwroot\ntadmin> Line 12 is the 'while' lineOne of the differences between PHP 4 COM and PHP 5 COM is that PHP doesn't do magic for IEnumXXX interfaces, and that is what I suspect the problem is here. That means that the magical $obj->next() stuff won't work, and should never have worked in the first place, because they aren't really methods of the com object, but of an iterator interface. (The PHP 4 COM stuff had quite a few of these hacks). The plan for PHP 5 is to allow this: foreach ($comUsers as $user) { $uClass = $obj->Class; $uName = $obj->Name; echo "$uName \t $uClass \n\r"; } but to implement that, I'm waiting for some engine magic, so I'll prod the relevant people about it.of course, I meant this: foreach ($comUsers as $user) { $uClass = $user->Class; $uName = $user->Name; echo "$uName \t $uClass \n\r"; } I'll look into the API docs for ADSI later to sanity check my other comments also.