http://qs321.pair.com?node_id=245122


in reply to Win32::OLE Password Change?

You seem a little confused but then I may be misunderstanding. The first example fragment uses WMI and the second uses ADSI through the NT namespace WinNT:://. root\cimv2 is not a user it is a namespace or context(?) for WMI. You don't need to connect with WMI to use ADSI. Also in the code:

$myDomain = Win32::OLE->GetObject("WinNT://$server/$pworduser")

The code returns a user object not a domain object. $pworduser is not the username of the account that you are using to establish privilege to alter user accounts. It should probably be something like:

$objUser = Win32::OLE->GetObject("WinNT://$server/$pworduser")

Look at Problems with Win32::OLE and ADSI in which rob_au gives code that uses an alternative username and password to connect to ADSI. Once connected you can change people's passwords with

$objUser->SetPassword($password);

When you say you are having troubles connecting to WinNT with "Invalid namespace" errors is that in the second code fragment? What NT version are you using? If you are using NT4 you may need to install Active Directory Service Interfaces for Microsoft Windows NT Server 4.0

Unfortunately I am making assumptions and I can't test this at home as I haven't the right platforms.