Esteemed monks -
For all the OLE guru's... I'm trying to change a user's password through OLE. I want to keep my code consistent in using OLE instead of resorting to Win32::AdminMisc. For the rest of my code, I bind to WMI with the following:
@host = ($server,"root/cimv2",$user,$password);
$localWMI = Win32::OLE->new('WbemScripting.SWbemLocator') or die "Cann
+ot access WMI on local machine: ", Win32::OLE->LastError;
$WMI = $localWMI->ConnectServer(@host) or die "Cannot access WMI on re
+mote machine: ", Win32::OLE->LastError;
I want to be able to do a similar bind to WINNT where I can use an alternate moniker than what I'm logged in with (as above). The only way I know to change a password using OLE is:
if ($myDomain = Win32::OLE->GetObject("WinNT://$server/$pworduser")) {
$result=$myDomain->ChangePassword($oldpassword, $newpassword);
print "Result: $result\n";
}
else {
print "Couldn't connect :-(\n";
}
But this only uses the logged in credentials as a moniker. Is there a host array I can use to supply different credentials to connect to WINNT instead of root\cimv2? Or is there another way I can change a password of a user (it doesn't seem as if the Win32_User object has any methods associated with it unforuntately...). All my attempts to connect to WINNT using scripting or wbemtest.exe have results in "Invalid namespace" failures. Any thoughts or comments are appreciated!