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.


In reply to Re: Win32::OLE Password Change? by blm
in thread Win32::OLE Password Change? by jpavel

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.