Hi, I have a similar problem. But my script works 7 out of 10 times. The remaining 3 times, instead of executing the script, the browser pop up a dialogue box to save the “.pl” file. The gui page has many links which is written in mod perl and the problem occurs only for one script. The mime-type and the content-type is declared as required. I have done a lot of analysis, but could not able to resolve the problem.
The earlier version works fine. The new version includes centrified code for using the windows id to login instead of UNIX id through browser. That’s where the problem occurs.
Newly included code is pasted below:
sub verify_login
{
print STDERR "in sub verify_login
" ;
#my $userid = @[0];
#my $passwd = @[1];
my $user_id = $[0] ;
my $password = $[1];
print STDERR "JBC: Checking userid $user_id $nt_id
";
my $errCode = 1;
my $nt_id = /bin/adquery user -M ${user_id}
;
print STDERR "JBC: Checking userid $user_id $nt_id
";
chomp ($nt_id);
$user_id = /bin/adquery user -n ${user_id}
;
chomp ($user_id);
print STDERR "JBC: Checking userid $user_id $nt_id
";
print STDERR " Inside of verify_login function - Testing : Function : verify login : userid - $user_id nt_id $nt_id
";
print &::HTMLHeader(“Verifying $user_id PXED Username $nt_id”);
print &::PrintBanner;
my $ldap = Net::LDAP->new($::appinfo{PXEDSVR});
my $mesg = $ldap->bind($::appinfo{PXEDSVCACCT},password=>$::appinfo{PXEDPASSWD});
print STDERR $mesg->error(), " binded
";
$mesg->code && die $mesg->error;
$ENV{REMOTE_USER} = $user_id;
print "<br>CDARS (<i>‘Unix’</i>) Username: $user_id REMOTE_USER: $ENV{REMOTE_USER})
";
print "<br>PXED (<i>‘Windows’</i>) Username: $nt_id
";
print “<br>Verifying PXED (<i>‘Windows’</i>) Password…
“;
#now search for a username
$mesg = $ldap->search(base=>“dc=pxed,dc=pfizer,dc=com”, filter=>”(cn=${nt_id})”, sizelimit=>1);
# now bind the username
print STDERR “<p>” . $mesg->error . "
</pre>
";
#$mesg->code && die $mesg->error;
if ( $mesg->count != 1 ) {
print STDERR " ldap search found 1 search entry inside message count
";
print "<p><font color=‘red’>Couldn’t find userid $nt_id in PXED.</font>
";
print "<br>Hit the Back button and try again.
";
$errCode = 0;
}
else {
foreach my $entry ($mesg->entries) {
print STDERR " Starting for loop ldap search
";
$entry->dump;
my $dn = $entry->dn();
my $displayName = $entry->get_value(‘displayName’);
my $loginDisabled = $entry->get_value(‘loginDisabled’);
my $deactivationDate = $entry->get_value(‘pfizerDeActivationDate’);
my $mail = $entry->get_value(‘mail’);
my $position = $entry->get_value(‘pfizerPositionDescription’);
print "<p>LDAP dn:$dn
<br>Display Name: $displayName
<br>is Login Disabled: $loginDisabled
DeActivation Date $deactiva
tionDate
<br>email: $mail
<br>Position: $position
";
if ( $loginDisabled eq “TRUE” ) {
print STDERR " Inside if login disabled true
";
print "<p><font color=‘red’>Account DISABLED</font>
";
$pxeduser{$ENV{REMOTE_USER}} = “”; # wipe it out!
print "Please hit the BACK button and try again
";
$errCode = 0;
} else {
print STDERR " Inside else login disabled false
“;
# verify the password
# my $mesg = $ldap->bind(”$dn",password=>"$passwd");
my $mesg = $ldap->bind("$dn",password=>"$password");
print “<p>”, $mesg->error(), "<b> when authenticating user $displayName</b><p>
";
if ( $mesg->code ) {
print STDERR " Inside if message code true
";
# not ok, have 'em try again!
print STDERR $mesg->error(), " -- $displayName
";
$pxeduser{$ENV{REMOTE_USER}} = “”; # wipe it out!
print "Please hit the BACK button and try again
";
$errCode = 0;
}
else {
print STDERR " Inside else message code true
";
print “user account verfied
<p>”;
# now add to global hash
# ok the password is good, save to the LDAP database
$ENV{REMOTE_USER} = $user_id ;
#JBC Was here
#$pxeduser{$ENV{REMOTE_USER}} = $user_id;
#$cdarsuser{$user_id} = $ENV{REMOTE_USER};
#print $pxed_fh "$ENV{REMOTE_USER}:$user_id
";
#print $cd_fh "$user_id:$ENV{REMOTE_USER}
";
$pxeduser{$user_id} = $nt_id;
$cdarsuser{$user_id} = $user_id;
$pxeduser{$nt_id} = $nt_id;
$cdarsuser{$nt_id} = $user_id;
print $pxed_fh "$nt_id:$user_id
";
print $cd_fh "$user_id:$nt_id
";
print $pxed_fh "$user_id:$user_id
";
print $cd_fh "$nt_id:$nt_id
";
#JBC done
#JBC done
print "User added to CDARS’s PXED User database.
";
print "Thank you.
";
print "<p><input type=button value=‘Continue’ onClick=“window.location=’$::input{url}’”>
";
print STDERR "Inside Message Code.
";
} #$mesg->code
print STDERR " end of the block loginDisabled .
";
} # loginDisabled
print STDERR "looping for loop .
";
} # for loop
} # main if
print STDERR "end of the verify login
";
return $errCode ;
}
sub login {
print STDERR "in sub login
" ;
my $r = shift;
my $r_uri = $r->uri;
my %param = $r->method eq ‘POST’ ? $r->content : $r->args;
my $user_id = $param{‘user_id’};
my $nt_id;
print STDERR "login: user_id:$user_id|
";
if( $user_id ) {
$user_id = /bin/adquery user -n "$user_id"|head -1
;
chomp ($user_id);
print STDERR "login1: user_id:$user_id nt_id:$nt_id REMOTE_USER:$ENV{REMOTE_USER}
";
$nt_id = /bin/adquery user -M "$user_id"|head -1
;
chomp ($nt_id);
print STDERR "login2: user_id:$user_id nt_id:$nt_id REMOTE_USER:$ENV{REMOTE_USER}
";
}
my $password = $param{‘password’};
my $msg = “”;
my $url = $param{url} || getURL($r, %param);
if ($user_id && $password) {
# my $pwd = /bin/egrep "^$user_id\:" $::APPDIR/etc/cdars-ypcat | /bin/cut -d":" -f2
;
#chomp($pwd);
#if ($pwd && (crypt($password, $pwd) eq $pwd)) {
if (verify_login($nt_id, $password)) { ------ new function is called here
existing code
}
}
The above code is included in login.pm page and the pop up error occurs for top.pl page (there is no change in top.pl page)
Could you please help me here to find out the problem.
Regards
Ravi