Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

finding NT username

by nop (Hermit)
on Aug 25, 2000 at 14:00 UTC ( [id://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 }


    --=Lolindrath=--
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
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'};
        cheers,
        ybiC

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
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?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (3)
As of 2024-04-20 02:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found