Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Windows Logon ID capture

by dtharby (Acolyte)
on Jun 14, 2005 at 10:20 UTC ( [id://466459]=perlquestion: print w/replies, xml ) Need Help??

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

Hi All, Is it at all possible to get the current Logon ID of a
user running a perl script ?

Basically I want to write a GUI front-end and would like
the script to be able to capture the user that is
using the gui without them actually typing anything in.

Thanks in advance for your thoughts and ideas
Danny Update :-- as marto and kaif have mentioned, I have managed to source a copy of Perl In A Nutshell.. :-)

Replies are listed 'Best First'.
Re: Windows Logon ID capture
by marto (Cardinal) on Jun 14, 2005 at 10:34 UTC
    Hi,

    Win32::LoginName()
    "Returns the username of the owner of the current Perl process."
    From Perl in a Nutshell (ISBN 1565922867) - 19.17 Win32 Extensions.

    Hope this helps,

    Cheers

    Martin
        TANSTAAFL Its only "free" for 14 days. Then its $19.95 /month and up. I don't begrudge them their business though.

        I have seen various bootleg copies mounted to the internet before. Be aware that is copyright infringement and the O'Reilly police will get you.
      Thanks Martin
      I attempted to assign the value of Win32::Login() to a scalar ($script_runner) but I get the following error

      Can't locate auto/Win32/Login.al in @INC

      I have checked and it is indeed right

      I am using ActiveState Perl 5.8 build 811


      UPDATE: have used ppm to check for module but have had not luck finding the Win32 one....
        Hi,

        Have you had a look here.
        Hope this helps.

        Cheers,

        Martin
        You will also need to put "use Win32;" in your script before you call the function. I don't think you'll need to PPM it, I believe its one of the core modules.
        The function is Win32::LoginName

        my $script_runner = Win32::LoginName; # ^^^^

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (2)
As of 2024-04-26 00:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found