<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Perl LWP Authentication Scripts... in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/perl-lwp-authentication-scripts/m-p/5074775#M93246</link>
    <description>Can you guys help me with this?&lt;BR /&gt;&lt;BR /&gt;I have a site protected by siteminder.....&lt;BR /&gt;&lt;BR /&gt;Thus when going to the internal URL, it redirects us to a siteminder username/apssword page, then redirects us back to the original site.&lt;BR /&gt;&lt;BR /&gt;How can i login and pull the page via lwp?&lt;BR /&gt;&lt;BR /&gt;Here is my code:&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/perl&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;use English;&lt;BR /&gt;use strict;&lt;BR /&gt;use CGI ();&lt;BR /&gt;use LWP::UserAgent ();&lt;BR /&gt;use HTTP::Request::Common qw(POST);&lt;BR /&gt;#use LWP::Debug qw( + );&lt;BR /&gt;&lt;BR /&gt;my $Webjump = '&lt;A href="https://blah.com/siteminderagent/forms/login.fcc?TYPE=33554433&amp;amp;REALMOID=06-00034bb7-e037-116f" target="_blank"&gt;https://blah.com/siteminderagent/forms/login.fcc?TYPE=33554433&amp;amp;REALMOID=06-00034bb7-e037-116f&lt;/A&gt;&lt;BR /&gt;-8241-808d67a50008&amp;amp;GUID=&amp;amp;SMAUTHREASON=0&amp;amp;METHOD=GET&amp;amp;SMAGE NTNAME=$SM$6u%2by8Xv45zujpG8vqd8c%2fvGZPwkzRg6Ka38 kNya45FRtm&lt;BR /&gt;Gxbt4%2fdZsHY6%2ftkVw44&amp;amp;TARGET=$SM$%2fcgi-bin%2fTISLogReview%2findex%2ecgi';&lt;BR /&gt;&lt;BR /&gt;my $red = '&lt;A href="https://blah.com/cgi-bin/TISLogReview/index.cgi';" target="_blank"&gt;https://blah.com/cgi-bin/TISLogReview/index.cgi';&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;sub main ()&lt;BR /&gt;{&lt;BR /&gt;my $cgi = new CGI();&lt;BR /&gt;my $redirect = "$Webjump";&lt;BR /&gt;&lt;BR /&gt;my @parameterNames = $cgi-&amp;gt;param();&lt;BR /&gt;foreach my $parameterName (@parameterNames) {&lt;BR /&gt;my $parameterValue = $cgi-&amp;gt;param($parameterName);&lt;BR /&gt;if ($parameterName eq "USER"){&lt;BR /&gt;my $USER = $parameterValue;&lt;BR /&gt;}&lt;BR /&gt;elsif ($parameterName eq "PASSWORD") {&lt;BR /&gt;my $secretname = $parameterValue;&lt;BR /&gt;}&lt;BR /&gt;else&lt;BR /&gt;{&lt;BR /&gt;printError($cgi,&lt;BR /&gt;"Illegal parameter $parameterName passed to sso.pl");&lt;BR /&gt;return();&lt;BR /&gt;}&lt;BR /&gt;$redirect .= "$parameterName=$parameterValue&amp;amp;";&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;print($cgi-&amp;gt;redirect($redirect)); #=&amp;gt; This works!!&lt;BR /&gt;&lt;BR /&gt;# =&amp;gt; BELOW ARE SOME OF THE POST METHODS I TRIED&lt;BR /&gt;&lt;BR /&gt;my $userAgent = new LWP::UserAgent();&lt;BR /&gt;push @{ $userAgent-&amp;gt;requests_redirectable }, 'POST';&lt;BR /&gt;&lt;BR /&gt;#METHOD 1&lt;BR /&gt;my $req = new HTTP::Request POST =&amp;gt; $Webjump;&lt;BR /&gt;my $req = POST $Webjump,&lt;BR /&gt;['USER' =&amp;gt; 'username',&lt;BR /&gt;'PASSWORD' =&amp;gt; 'password'];&lt;BR /&gt;my $res = $userAgent-&amp;gt;request($req);&lt;BR /&gt;my $contentString = $res-&amp;gt;as_string;&lt;BR /&gt;&lt;BR /&gt;my $response =new HTTP::Request GET =&amp;gt; $red;&lt;BR /&gt;print $response-&amp;gt;content;&lt;BR /&gt;&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;# Kick off the script&lt;BR /&gt;main();&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Here is the output:&lt;BR /&gt;&lt;BR /&gt;# ./plate.pl&lt;BR /&gt;Status: 302 Moved&lt;BR /&gt;Location: &lt;A href="https://blah.com/siteminderagent/for...e037-116f-8241" target="_blank"&gt;https://blah.com/siteminderagent/for...e037-116f-8241&lt;/A&gt;&lt;BR /&gt;-808d67a50008&amp;amp;GUID=&amp;amp;SMAUTHREASON=0&amp;amp;METHOD=GET&amp;amp;SMAGE NTNAME=$SM$6u%2by8Xv45zujpG8vqd8c%2fvGZPwkzRg6Ka38 kNya45FRtmGxbt4&lt;BR /&gt;%2fdZsHY6%2ftkVw44&amp;amp;TARGET=$SM$%2fcgi-bin%2fTISLogReview%2findex%2ecgi&lt;BR /&gt;&lt;BR /&gt;LWP::UserAgent::new: ()&lt;BR /&gt;LWP::UserAgent::request: ()&lt;BR /&gt;LWP::UserAgent::send_request: POST &lt;A href="https://uihs.nj.ssmb.com/sitemindera...433&amp;amp;REALMOID=0" target="_blank"&gt;https://uihs.nj.ssmb.com/sitemindera...433&amp;amp;REALMOID=0&lt;/A&gt;&lt;BR /&gt;6-00034bb7-e037-116f-8241-808d67a50008&amp;amp;GUID=&amp;amp;SMAUTHREASON=0&amp;amp;METHOD=GET&amp;amp;SMAGE NTNAME=$SM$6u%2by8Xv45zujpG8vqd8c%2fvGZP&lt;BR /&gt;wkzRg6Ka38kNya45FRtmGxbt4%2fdZsHY6%2ftkVw44&amp;amp;TARGET =$SM$%2fcgi-bin%2fTISLogReview%2findex%2ecgi&lt;BR /&gt;LWP::UserAgent::_need_proxy: Not proxied&lt;BR /&gt;LWP:rotocol::http::request: ()&lt;BR /&gt;LWP::UserAgent::request: Simple response: Found&lt;BR /&gt;LWP::UserAgent::request: ()&lt;BR /&gt;LWP::UserAgent::send_request: POST &lt;A href="https://uihs.nj.ssmb.com/cgi-bin/TISLogReview/index.cgi" target="_blank"&gt;https://uihs.nj.ssmb.com/cgi-bin/TISLogReview/index.cgi&lt;/A&gt;&lt;BR /&gt;LWP::UserAgent::_need_proxy: Not proxied&lt;BR /&gt;LWP:rotocol::http::request: ()&lt;BR /&gt;LWP:rotocol::collect: read 859 bytes&lt;BR /&gt;LWP::UserAgent::request: Simple response: OK&lt;BR /&gt;&lt;BR /&gt;-------------------------------------------&lt;BR /&gt;&lt;BR /&gt;Why isn't it retrieving my content?&lt;BR /&gt;my $response =new HTTP::Request GET =&amp;gt; $red;&lt;BR /&gt;print $response-&amp;gt;content;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;-Thanks in Advance, &lt;BR /&gt;</description>
    <pubDate>Wed, 17 Oct 2007 13:46:29 GMT</pubDate>
    <dc:creator>jmckinzie</dc:creator>
    <dc:date>2007-10-17T13:46:29Z</dc:date>
    <item>
      <title>Perl LWP Authentication Scripts...</title>
      <link>https://community.hpe.com/t5/operating-system-linux/perl-lwp-authentication-scripts/m-p/5074775#M93246</link>
      <description>Can you guys help me with this?&lt;BR /&gt;&lt;BR /&gt;I have a site protected by siteminder.....&lt;BR /&gt;&lt;BR /&gt;Thus when going to the internal URL, it redirects us to a siteminder username/apssword page, then redirects us back to the original site.&lt;BR /&gt;&lt;BR /&gt;How can i login and pull the page via lwp?&lt;BR /&gt;&lt;BR /&gt;Here is my code:&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/perl&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;use English;&lt;BR /&gt;use strict;&lt;BR /&gt;use CGI ();&lt;BR /&gt;use LWP::UserAgent ();&lt;BR /&gt;use HTTP::Request::Common qw(POST);&lt;BR /&gt;#use LWP::Debug qw( + );&lt;BR /&gt;&lt;BR /&gt;my $Webjump = '&lt;A href="https://blah.com/siteminderagent/forms/login.fcc?TYPE=33554433&amp;amp;REALMOID=06-00034bb7-e037-116f" target="_blank"&gt;https://blah.com/siteminderagent/forms/login.fcc?TYPE=33554433&amp;amp;REALMOID=06-00034bb7-e037-116f&lt;/A&gt;&lt;BR /&gt;-8241-808d67a50008&amp;amp;GUID=&amp;amp;SMAUTHREASON=0&amp;amp;METHOD=GET&amp;amp;SMAGE NTNAME=$SM$6u%2by8Xv45zujpG8vqd8c%2fvGZPwkzRg6Ka38 kNya45FRtm&lt;BR /&gt;Gxbt4%2fdZsHY6%2ftkVw44&amp;amp;TARGET=$SM$%2fcgi-bin%2fTISLogReview%2findex%2ecgi';&lt;BR /&gt;&lt;BR /&gt;my $red = '&lt;A href="https://blah.com/cgi-bin/TISLogReview/index.cgi';" target="_blank"&gt;https://blah.com/cgi-bin/TISLogReview/index.cgi';&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;sub main ()&lt;BR /&gt;{&lt;BR /&gt;my $cgi = new CGI();&lt;BR /&gt;my $redirect = "$Webjump";&lt;BR /&gt;&lt;BR /&gt;my @parameterNames = $cgi-&amp;gt;param();&lt;BR /&gt;foreach my $parameterName (@parameterNames) {&lt;BR /&gt;my $parameterValue = $cgi-&amp;gt;param($parameterName);&lt;BR /&gt;if ($parameterName eq "USER"){&lt;BR /&gt;my $USER = $parameterValue;&lt;BR /&gt;}&lt;BR /&gt;elsif ($parameterName eq "PASSWORD") {&lt;BR /&gt;my $secretname = $parameterValue;&lt;BR /&gt;}&lt;BR /&gt;else&lt;BR /&gt;{&lt;BR /&gt;printError($cgi,&lt;BR /&gt;"Illegal parameter $parameterName passed to sso.pl");&lt;BR /&gt;return();&lt;BR /&gt;}&lt;BR /&gt;$redirect .= "$parameterName=$parameterValue&amp;amp;";&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;print($cgi-&amp;gt;redirect($redirect)); #=&amp;gt; This works!!&lt;BR /&gt;&lt;BR /&gt;# =&amp;gt; BELOW ARE SOME OF THE POST METHODS I TRIED&lt;BR /&gt;&lt;BR /&gt;my $userAgent = new LWP::UserAgent();&lt;BR /&gt;push @{ $userAgent-&amp;gt;requests_redirectable }, 'POST';&lt;BR /&gt;&lt;BR /&gt;#METHOD 1&lt;BR /&gt;my $req = new HTTP::Request POST =&amp;gt; $Webjump;&lt;BR /&gt;my $req = POST $Webjump,&lt;BR /&gt;['USER' =&amp;gt; 'username',&lt;BR /&gt;'PASSWORD' =&amp;gt; 'password'];&lt;BR /&gt;my $res = $userAgent-&amp;gt;request($req);&lt;BR /&gt;my $contentString = $res-&amp;gt;as_string;&lt;BR /&gt;&lt;BR /&gt;my $response =new HTTP::Request GET =&amp;gt; $red;&lt;BR /&gt;print $response-&amp;gt;content;&lt;BR /&gt;&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;# Kick off the script&lt;BR /&gt;main();&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Here is the output:&lt;BR /&gt;&lt;BR /&gt;# ./plate.pl&lt;BR /&gt;Status: 302 Moved&lt;BR /&gt;Location: &lt;A href="https://blah.com/siteminderagent/for...e037-116f-8241" target="_blank"&gt;https://blah.com/siteminderagent/for...e037-116f-8241&lt;/A&gt;&lt;BR /&gt;-808d67a50008&amp;amp;GUID=&amp;amp;SMAUTHREASON=0&amp;amp;METHOD=GET&amp;amp;SMAGE NTNAME=$SM$6u%2by8Xv45zujpG8vqd8c%2fvGZPwkzRg6Ka38 kNya45FRtmGxbt4&lt;BR /&gt;%2fdZsHY6%2ftkVw44&amp;amp;TARGET=$SM$%2fcgi-bin%2fTISLogReview%2findex%2ecgi&lt;BR /&gt;&lt;BR /&gt;LWP::UserAgent::new: ()&lt;BR /&gt;LWP::UserAgent::request: ()&lt;BR /&gt;LWP::UserAgent::send_request: POST &lt;A href="https://uihs.nj.ssmb.com/sitemindera...433&amp;amp;REALMOID=0" target="_blank"&gt;https://uihs.nj.ssmb.com/sitemindera...433&amp;amp;REALMOID=0&lt;/A&gt;&lt;BR /&gt;6-00034bb7-e037-116f-8241-808d67a50008&amp;amp;GUID=&amp;amp;SMAUTHREASON=0&amp;amp;METHOD=GET&amp;amp;SMAGE NTNAME=$SM$6u%2by8Xv45zujpG8vqd8c%2fvGZP&lt;BR /&gt;wkzRg6Ka38kNya45FRtmGxbt4%2fdZsHY6%2ftkVw44&amp;amp;TARGET =$SM$%2fcgi-bin%2fTISLogReview%2findex%2ecgi&lt;BR /&gt;LWP::UserAgent::_need_proxy: Not proxied&lt;BR /&gt;LWP:rotocol::http::request: ()&lt;BR /&gt;LWP::UserAgent::request: Simple response: Found&lt;BR /&gt;LWP::UserAgent::request: ()&lt;BR /&gt;LWP::UserAgent::send_request: POST &lt;A href="https://uihs.nj.ssmb.com/cgi-bin/TISLogReview/index.cgi" target="_blank"&gt;https://uihs.nj.ssmb.com/cgi-bin/TISLogReview/index.cgi&lt;/A&gt;&lt;BR /&gt;LWP::UserAgent::_need_proxy: Not proxied&lt;BR /&gt;LWP:rotocol::http::request: ()&lt;BR /&gt;LWP:rotocol::collect: read 859 bytes&lt;BR /&gt;LWP::UserAgent::request: Simple response: OK&lt;BR /&gt;&lt;BR /&gt;-------------------------------------------&lt;BR /&gt;&lt;BR /&gt;Why isn't it retrieving my content?&lt;BR /&gt;my $response =new HTTP::Request GET =&amp;gt; $red;&lt;BR /&gt;print $response-&amp;gt;content;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;-Thanks in Advance, &lt;BR /&gt;</description>
      <pubDate>Wed, 17 Oct 2007 13:46:29 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/perl-lwp-authentication-scripts/m-p/5074775#M93246</guid>
      <dc:creator>jmckinzie</dc:creator>
      <dc:date>2007-10-17T13:46:29Z</dc:date>
    </item>
    <item>
      <title>Re: Perl LWP Authentication Scripts...</title>
      <link>https://community.hpe.com/t5/operating-system-linux/perl-lwp-authentication-scripts/m-p/5074776#M93247</link>
      <description>SiteMinder is complicated, so what you need will depend on how the other end is set up to operate. But one thing I see is that you don't seem to be setting a cookie_jar in LWP. SiteMinder authentication sometimes uses cookies to identify a client after login.</description>
      <pubDate>Wed, 17 Oct 2007 17:19:05 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/perl-lwp-authentication-scripts/m-p/5074776#M93247</guid>
      <dc:creator>Heironimus</dc:creator>
      <dc:date>2007-10-17T17:19:05Z</dc:date>
    </item>
    <item>
      <title>Re: Perl LWP Authentication Scripts...</title>
      <link>https://community.hpe.com/t5/operating-system-linux/perl-lwp-authentication-scripts/m-p/5074777#M93248</link>
      <description>Had to create a cookie container.&lt;BR /&gt;&lt;BR /&gt;# Open Cookie Object&lt;BR /&gt;my $cookie_jar = HTTP::Cookies-&amp;gt;new(&lt;BR /&gt;file    =&amp;gt;      "/adminweb/usm/tlrs/cookies.t",&lt;BR /&gt;autosave =&amp;gt; 1,&lt;BR /&gt;);&lt;BR /&gt;</description>
      <pubDate>Thu, 31 Jan 2008 15:01:03 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/perl-lwp-authentication-scripts/m-p/5074777#M93248</guid>
      <dc:creator>jmckinzie</dc:creator>
      <dc:date>2008-01-31T15:01:03Z</dc:date>
    </item>
  </channel>
</rss>

