Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: How to get the User login name in Win2000

by jfluhmann (Scribe)
on Sep 08, 2006 at 13:46 UTC ( [id://571968]=note: print w/replies, xml ) Need Help??


in reply to How to get the User login name in Win2000

Something I used to use when I was working on a desktop management system was similar to the following:

#!/usr/bin/perl use strict; use warnings; use Win32::OLE 'in'; $Win32::OLE::Warn = 3; my $server = shift; my @users = (); getLocalUsers($server,\@users); print "Local User Accounts for $server:\n"; foreach( @users ) { print $_ . "\n"; } # USE: getLocalUsers(<computer>,\@<list>) sub getLocalUsers { my $strComputer = shift; my $users = shift; my $colAccounts = Win32::OLE->GetObject("WinNT://" . $strComputer); $colAccounts->{'Filter'} = ["user"]; map { push @{$users}, $_->{'Name'}; } in $colAccounts; }

The @users seemed to also include user accounts that current processes were running under. You could probably just filter them out.

Jeremy

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (4)
As of 2024-04-25 13:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found