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