[prev in list] [next in list] [prev in thread] [next in thread] 

List:       perl-win32-web
Subject:    RE: substitution operator not working under ASP?
From:       "Duane Lakoduk" <dlakoduk () mn ! rr ! com>
Date:       2003-10-02 16:21:43
[Download RAW message or body]

> -----Original Message-----
> From: Dan Ratzlaff
> 
> I'm testing out getting authentication variables from IIS via 
> ASP, and wanted to strip the domain name off the username.  
> Here's my page source:
> 
>   <%@ Language=PerlScript %>
>   <html>
>   <head><title>New Page 1</title></head>
>   <body>
>   <%
>   use strict;
>   use vars qw( $Request $Response );
>   my $username = $Request->ServerVariables("AUTH_USER");
>   my $authtype = $Request->ServerVariables("AUTH_TYPE");
>   %>
>   <p>Authentication type was <%=$authtype%>
>   <p>Username is: <%=$username%></p>
>   <%
>   $username =~ s/DOMAIN\\//;
>   %>
>   <p>Modified username: <%=$username%></p>
>   </html>
> 
> But this page is outputting:
> 
>   Authentication type was NTLM 
> 
>   Username is: DOMAIN\username
> 
>   Modified username: DOMAIN\username
> 
<clip></clip>
>
> Am I missing something, or is something weird going on here?
> 


I am new with perl and perlscript but have experience in ASP using
vbscript/javascript.  
The problem seems to be that you need to dereference the "AUTH_USER" Server
variable.
Try this:

<%
use strict;
use vars qw( $Request $Response );
my $username = $Request->ServerVariables("AUTH_USER")->{Item};

my @dom = split(/\\/, $username);
my $domain = $dom[0];
my $name = $dom[1];
%>
<p>Username: <%=$username%> </p>
<%
$username =~ s/$domain\\//i;
%>
<p>Modified Username: <%=$username%> </p>
<p>Domain: <%=$domain %> </p>
<p>Name: <%=$name%> </p>


Results are:

Username: DOMAIN\username
Modified username: username
Domain: DOMAIN
Name: username


["winmail.dat" (application/ms-tnef)]
_______________________________________________
Perl-Win32-Web mailing list
Perl-Win32-Web@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic