Active Directory login User

A

Armando

Can someone help me with this problem.
Is there a way that I can find with Perl on what Windows machine a
Domain user account is logged in?
 
D

D. Marxsen

Armando said:
Is there a way that I can find with Perl on what Windows machine a
Domain user account is logged in?

Sorry, I don't know much about WinDoze administrator stuff (what's the
difference between a user and a domain user?). Anyhow, try:

printf("Computer: %s\n",$ENV{'COMPUTERNAME'});


Cheers,
Detlef.
 
P

Peter Wyzl

"D. Marxsen" <[email protected] (replace z with h, spam
protection)> wrote in message news:[email protected]...
Sorry, I don't know much about WinDoze administrator stuff (what's the
difference between a user and a domain user?). Anyhow, try:

printf("Computer: %s\n",$ENV{'COMPUTERNAME'});

Which happily prints the local host name...

try $ENV{'USERDOMAIN'} and $ENV{'USERNAME'}, They contain what you are
asking for.
 
T

Thomas Kratz

Armando said:
Can someone help me with this problem.
Is there a way that I can find with Perl on what Windows machine a
Domain user account is logged in?

There are two principle ways depending on your setup.
If you are still using Netbios over TCPIP, the old Lanmanager calls will
work and you will be able to use Win32::Lanman.

First get a list of computers with Win32::Lanman::NetServerEnum.
Either loop over all domain controllers and look at the output of
Win32::Lanman::NetSessionEnum or loop over all workstations and get the
logged on users with Win32::Lanman::NetWkstaUserEnum.
For details read the docs that come with the module.

Without the Lanmanager protocol you have to rely on the WMI and ADSI
interfaces that you can use with Win32::OLE (See the Microsoft docs
available on their website. But don't expect an easy solution. The classes
are a real mess, I have never seen something uglier, ... oh wait yes I do:
the Win32 API could win the competition).
Google for examples how to use WMI with perl. There should be at least 3
threads from the last 2 months.

Thomas

--
$/=$,,$_=<DATA>,s,(.*),$1,see;__END__
s,^(.*\043),,mg,@_=map{[split'']}split;{#>J~.>_an~>>e~......>r~
$_=$_[$%][$"];y,<~>^,-++-,?{$/=--$|?'"':#..u.t.^.o.P.r.>ha~.e..
'%',s,(.),\$$/$1=1,,$;=$_}:/\w/?{y,_, ,,#..>s^~ht<._..._..c....
print}:y,.,,||last,,,,,,$_=$;;eval,redo}#.....>.e.r^.>l^..>k^.-
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,430
Messages
2,571,676
Members
48,796
Latest member
Greg L.

Latest Threads

Top