Hi,
I have just joined this forum because this is where the gurus are. I am not a regular perl programmer and actually work on the procurement product. I have to implement Single sign on into this application from procurement homepage. The procurement homepage is authenticated over siteminder. This product application is not on siteminder though and has its own webserver(IIS). To implement single sign on I have just one sample perl file which requires to be modified for my configuration. I do not have ready access to the web server to change permissions et al. I have access to the most files on it provided by the product company. I do not want to access any DB to authenticate because the link to logon into this product (from the homepage) is shown only to users active in the DB.
I managed to to do a redirect from the perl file to the Ariba server and login successfully. But what I want to do is the Post to avoid getting the parameters on the URL.
I have couple of problems: 1. I am not aware of how to debug the code? 2. I tried various combinations to post it but it each time resulted in either of:
(1) cgi error: headers not returned are: with nothing listedunder . (2) It does not post and a blank page is displayed or (3) HTTP 400 - Bad request.
So I do not know how to proceed or test the same. Can you please provide any light?
Here is the code which I am using:
use English;
use strict;
use CGI ();
use LWP::UserAgent ();
use HTTP::Request::Common qw(POST);
my $Webjump = "https://mydomain.com/IISProxy.asp?/webjump";
sub main ()
{
my $cgi = new CGI();
my $redirect = "$Webjump?";
my @parameterNames = $cgi->param();
foreach my $parameterName (@parameterNames) {
my $parameterValue = $cgi->param($parameterName);
if ($parameterName eq "SSOU"){
$SSOU = $parameterValue;
}
elsif ($parameterName eq "SSOS") {
$secretname = $parameterValue;
}
else
{
printError($cgi,
"Illegal parameter $parameterName passed to sso.pl");
return();
}
$redirect .= "$parameterName=$parameterValue&";
}
print($cgi->redirect($redirect)); #=> This works!!
# => BELOW ARE SOME OF THE POST METHODS I TRIED
#my $userAgent = new LWP::UserAgent();
#METHOD 1
#my $req = new HTTP::Request POST => $Webjump;
#my $req = POST $Webjump,
# ['SSOU' => '$SSOU',
# 'SSOS' => '$secretname'];
#my $res = $userAgent->request($req);
#my $contentString = $res->as_string;
#print("$contentString\n");
#$req->content_type('application/x-www-form-urlencoded');
#$req->content($redirect);
#METHOD 2
# my $form = [ "SSOU" => $SSOU,
# "SSOS" => $secretname];
#my $request = HTTP::Request::Common::POST($Webjump, $form);
#my $response = $userAgent->request($request);
#my $location = $BaseURL.$response->header('Location');
#$response->header('Location' => $location);
#my $contentString = $response->as_string;
#print("$contentString\n");
}
# Kick off the script
main();
I have just joined this forum because this is where the gurus are. I am not a regular perl programmer and actually work on the procurement product. I have to implement Single sign on into this application from procurement homepage. The procurement homepage is authenticated over siteminder. This product application is not on siteminder though and has its own webserver(IIS). To implement single sign on I have just one sample perl file which requires to be modified for my configuration. I do not have ready access to the web server to change permissions et al. I have access to the most files on it provided by the product company. I do not want to access any DB to authenticate because the link to logon into this product (from the homepage) is shown only to users active in the DB.
I managed to to do a redirect from the perl file to the Ariba server and login successfully. But what I want to do is the Post to avoid getting the parameters on the URL.
I have couple of problems: 1. I am not aware of how to debug the code? 2. I tried various combinations to post it but it each time resulted in either of:
(1) cgi error: headers not returned are: with nothing listedunder . (2) It does not post and a blank page is displayed or (3) HTTP 400 - Bad request.
So I do not know how to proceed or test the same. Can you please provide any light?
Here is the code which I am using:
use English;
use strict;
use CGI ();
use LWP::UserAgent ();
use HTTP::Request::Common qw(POST);
my $Webjump = "https://mydomain.com/IISProxy.asp?/webjump";
sub main ()
{
my $cgi = new CGI();
my $redirect = "$Webjump?";
my @parameterNames = $cgi->param();
foreach my $parameterName (@parameterNames) {
my $parameterValue = $cgi->param($parameterName);
if ($parameterName eq "SSOU"){
$SSOU = $parameterValue;
}
elsif ($parameterName eq "SSOS") {
$secretname = $parameterValue;
}
else
{
printError($cgi,
"Illegal parameter $parameterName passed to sso.pl");
return();
}
$redirect .= "$parameterName=$parameterValue&";
}
print($cgi->redirect($redirect)); #=> This works!!
# => BELOW ARE SOME OF THE POST METHODS I TRIED
#my $userAgent = new LWP::UserAgent();
#METHOD 1
#my $req = new HTTP::Request POST => $Webjump;
#my $req = POST $Webjump,
# ['SSOU' => '$SSOU',
# 'SSOS' => '$secretname'];
#my $res = $userAgent->request($req);
#my $contentString = $res->as_string;
#print("$contentString\n");
#$req->content_type('application/x-www-form-urlencoded');
#$req->content($redirect);
#METHOD 2
# my $form = [ "SSOU" => $SSOU,
# "SSOS" => $secretname];
#my $request = HTTP::Request::Common::POST($Webjump, $form);
#my $response = $userAgent->request($request);
#my $location = $BaseURL.$response->header('Location');
#$response->header('Location' => $location);
#my $contentString = $response->as_string;
#print("$contentString\n");
}
# Kick off the script
main();