Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Win32::NetAdmin

by devslashneil (Friar)
on Aug 11, 2003 at 02:06 UTC ( [id://282722]=perlquestion: print w/replies, xml ) Need Help??

devslashneil has asked for the wisdom of the Perl Monks concerning the following question:

Hi Everyone,

I have been having a little bit of trouble writing a script which simply changes the passwords of all the Users on my system.

At first when i called GroupGetMembers() i received the error 'GroupGetMembers() failed Overlapped I/O Operation'
However when i replaced this with the 'LocalGroupGetMembers()' call this error was removed.

Moving on i entered the 'UserGetAttributes()' call, however the script now produces the "failed Overlapped I/O" error for the 'UserGetAttributes()' call.

As there is no 'LocalUserGetAttributes()' subroutine i am very unsure what to do next.

I am running ActivePerl and the script has administrator priviledges.
If i have left out any information please just ask.

Any help would be much appreciated

Here is the code which produces the error.
use Win32::NetAdmin qw/LocalGroupGetMembers UserGetAttributes UserSetAttributes/; my @users; LocalGroupGetMembers("",'Users', \@users) or die "GroupGetMembers() failed: $^E\n"; for(@users) { my ($server, $userName, $password, $passwordAge, $privilege, $homeDir, $comment, $flags, $scriptPath) = (); UserGetAttributes("",$_,$password,$passwordAge,$privil +ege, $homeDir, $comment, $flags, $scriptPat +h ) or die "UserGetAttributes() failed +$^E"; print "$username :: $password\n"; }
Thanks a lot.

Neil Archibald
- /dev/IT -

Replies are listed 'Best First'.
Re: Win32::NetAdmin
by JamesNC (Chaplain) on Aug 11, 2003 at 05:36 UTC
    If you are Win2K or WinXP you can use the "net user" commands to modify passwords, attributes, add/delete users. Just automate that if you have a lot of users
    JamesNC
Re: Win32::NetAdmin
by BrowserUk (Patriarch) on Aug 11, 2003 at 08:09 UTC

    Try inserting a delay (sleep) just before the failing call. Start with something like 10 or 15 seconds and if that fixes the problem, slowly reduce the delay until problem comes back.


    Examine what is said, not who speaks.
    "Efficiency is intelligent laziness." -David Dunham
    "When I'm working on a problem, I never think about beauty. I think only how to solve the problem. But when I have finished, if the solution is not beautiful, I know it is wrong." -Richard Buckminster Fuller
    If I understand your problem, I can solve it! Of course, the same can be said for you.

      Yeah sorry i could have mentioned that, i even tried a sleep for 10 minutes but it didn't fix it :\

      Neil Archibald
      - /dev/IT -

        I can't reproduce this with AS 5.6 (633) / 5.8 (802) and Win32::NetAdmin v0.08.

        One thing I just noticed is that you are printing $^E (which looked fine to me first time around), but then I noticed that the pod for NetAdmin says

        When a function fails call Win32::NetAdmin::GetError() rather than GetLastError() or $^E to retrieve the error code.

        It's just possible that you are looking at the wrong error message?

        Have you tried this from another machine? Under a different account? On the domain server? Which versions of OS, perl, the module etc.


        Examine what is said, not who speaks.
        "Efficiency is intelligent laziness." -David Dunham
        "When I'm working on a problem, I never think about beauty. I think only how to solve the problem. But when I have finished, if the solution is not beautiful, I know it is wrong." -Richard Buckminster Fuller
        If I understand your problem, I can solve it! Of course, the same can be said for you.

Re: Win32::NetAdmin
by Anonymous Monk on Aug 11, 2003 at 12:57 UTC

    You may find that you need to specify a server for the UserGetAttributes() function. Try obtaining the PDC first and then do the operations.

    sub get_PDC { #Usage: $pdc=get_PDC($domain); my $dom=shift or return undef; my $server; Win32::NetAdmin::GetDomainController("", $dom, $server); return $server; }

    Then replace "" with $pdc in your userGetAttributes($pdc,...) call.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://282722]
Approved by DigitalKitty
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (6)
As of 2024-04-24 01:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found