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

Shouldn't it be possible to capture a list of users on a windows box by only using the Win32::API module? I attempted this but I am not a C programmer. Where did I go wrong? This code actually causes perl.exe to die with the following error:
The instruction at "0x71c42b8c" referenced memory at "0x00000000". The + memory could not be "written".

Still Learning,

Steve
#!perl use Win32::API; getUsers(); ################ sub getUsers{ #usage: #info: my ($server,$level,$filter,$buffptr); my $maxlen = 0xffffffff; if(!$NetUserEnum){$NetUserEnum = new Win32::API("netapi32", "NetUs +erEnum", ['P','N','N','N','N','N','N','N'], 'P') || return 0;} my $rtn=$NetUserEnum->Call( $server, #severname 0, #level 0-20 $filter, #filter $buffptr, #bufptr $maxlen, #prefmaxlen \%entread, #entriesread \%totalentries, #totalentries \%resumehwnd, #resumehandle ); }

Replies are listed 'Best First'.
Re: NetUserEnum using Win32::API
by NetWallah (Canon) on Feb 10, 2004 at 00:59 UTC
    This is a slightly updated version of the program from check for DISABLED account on win32. With very minor changes, it will get you your user list.

    Run it like this:
    perl <Prog-name> <Computer-name> <Computer-name>

    The first <Computer-name> replaces the domain name, and the second is for the domain controller name. This program works for NT/2000 style domain accounts as well.

    "When you are faced with a dilemma, might as well make dilemmanade. "

Re: NetUserEnum using Win32::API
by bart (Canon) on Feb 10, 2004 at 07:47 UTC
    Passing a Perl hash reference to a Win32 API call looks very wrong to me — let alone 3.
Re: NetUserEnum using Win32::API
by Anonymous Monk on Feb 10, 2004 at 06:56 UTC
    What's wrong with Win32::NetAdmin?
Re: NetUserEnum using Win32::API
by Anonymous Monk on Feb 10, 2004 at 15:29 UTC
    So is it possible using Win32::API or not? I am respectfully submitting this question to whom I consider to be some of the best perl programmers out there. If it is possible, how?