COM/DCOM

From: Date: Tue, 25 May 2010 07:01:20 +0000
Subject: COM/DCOM
Groups: php.general 
Request: Send a blank email to php-general+get-305501@lists.php.net to get a copy of this message
Hello, I'm trying to write a few scripts to help automate some Windows administration tasks. One of these is to add people to groups on different networked machines. I've written something like the following: <?php $computer = "TestComputer"; $groupName = "TestGroup"; $server_config = array('Server' => TestComputer' , 'Username' => 'TestUser' , 'Password' => 'TestPass'); // list all current group members $domainObject = new COM("WinNT://".$computer."/".$groupName.",group",$server_config) or die("Cannot create COM object"); foreach ($domainObject->Members as $var) { echo $var->Name."<br>"; } // add person to group $usertoadd = "APerson"; $domainUser = new COM("WinNT://DOMAIN/".$usertoadd.",user",$server_config) or die("Cannot create COM object "); $domainObject->Add($domainUser->ADsPath); ?> TestUser is a local administrative account on TestComputer. If I run apache using the standard local system account, the code lists the members of the group but refuses to add APerson. If I run apache with a domain administrator account it works fine, but I don't want to do this - I want to be able to pass the username and password of an account on the target machine that has permissions set up for this purpose. I've tried making changes using dcomcnfg on the target machine, but no luck so far. Does anyone have any experience in using COM functions and can spot anything I'm doing wrong or a misunderstanding in how it works? Thanks, Jon --------- This e-mail does not reflect the views or opinions of Travellers Tales (UK) Ltd or any other related TT Games group company.

« previous php.general (#305501) next »