Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

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)

Comment on finding NT username
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 CGI.pm, you can get the username via
    $cgi_object->remote_user()
    HTH
    //mikkoH
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'};
        cheers,
        ybiC
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
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 }


    --=Lolindrath=--

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (11)
As of 2014-09-02 08:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite cookbook is:










    Results (20 votes), past polls