|   | php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login | 
| 
  [2002-08-30 04:09 UTC] mario dot schmidt at mediavillage dot de
 Following code "should" list all NT-Usergroups of the given machinename or nt-domain. This works with ASP but not PHP :(...
Array $objComputer is created but it only consists of one recordset (the first one, the machine itself). But there should be more in it! (Groups, Users, Services)
<?php
$objComputer = new COM("WinNT://machinename");
echo $objComputer->Name." is a ".$objComputer->Class." and has following NT-Groups:<p>";
$objComputer->filter = array("Group");
foreach($objComputer as $group)
{
	print $group->name."<br>\n";
}
echo "Group listing complete.";
?>
And here the WORKING Code using ASP:
<% 
Set GroupObj = GetObject("WinNT://machinename")
   
strFilter = Array("Group") 
BaseObj.Filter= strFilter
Response.write "---- Select a Group ----<p>"
For Each Member in BaseObj
    Response.write Member.Name & "<br>"
Next
%>
BTW: "WinNT://" is a VALID COM-Data Provider!!!
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits             | |||||||||||||||||||||||||||||||||||||
|  Copyright © 2001-2025 The PHP Group All rights reserved. | Last updated: Fri Oct 31 04:00:01 2025 UTC | 
foreach only works with arrays, try while ($group = $objComputer->Next()) { ... }foreach only works with arrays, try while ($group = $objComputer->Next()) { ... }