Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked

finding NT username

by nop (Hermit)
on Aug 25, 2000 at 14:00 UTC ( #29596=perlquestion: print w/replies, xml ) Need Help??
nop has asked for the wisdom of the Perl Monks concerning the following question:

Hi. I'm using ActiveState Perl under NT. How can a perl script running on an IIS intranet web server determine the NT username of the person calling the page? This is all intranet stuff, nothing external. Thanks!
nop (EA)

Replies are listed 'Best First'.
Re: finding NT username
by lolindrath (Scribe) on Aug 25, 2000 at 16:50 UTC
    I'd use the Win32 Module that comes with ActivePerl
    $LoginName = Win32::LoginName

    And just in case you need to check if the user is on NT
    if ( Win32::IsWinNT ) { #Do Stuff }

Re: finding NT username
by mikkoh (Beadle) on Aug 25, 2000 at 14:12 UTC
    I'm not sure how this works in NT, but if you use, you can get the username via
Buzzcutbuddha (One way)-RE: finding NT usernames
by buzzcutbuddha (Chaplain) on Aug 25, 2000 at 16:36 UTC
    Well two things:
    In IIS, you need to require user authentication, otherwise, the machines will not send the authentication information, and then, if you have the Perl IIS mappings you can use the variable $Request->ServerVariables("REMOTE_USER")->Item which returns the authenticated user. That works in the actually ASP pages only.
    Running as a script, you may want to look into Win32::Eventlog and then send all page access to the EventLog running on your server.
RE: finding NT username (CGI environment var)
by ybiC (Prior) on Aug 25, 2000 at 14:14 UTC
    The CGI environment variable REMOTE_USER is the closest I know of.   It won't directly provide the NT username, but if your intranet authentication is provided by your domain controller(s), it should be right unless users have multiple IDs.

    Something like this should work:

    use CGI; print $ENV{'REMOTE_USER'};

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://29596]
Approved by root
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (11)
As of 2016-10-26 17:28 GMT
Find Nodes?
    Voting Booth?
    How many different varieties (color, size, etc) of socks do you have in your sock drawer?

    Results (345 votes). Check out past polls.