Hi Ophir,
Thanks for your extremely useful tips, I wasn't sending the request to the Validate.ASP page to start with, and my repository name was wrong as well. I fixed those, however I still can't authenticate.
The POST reqeust from IE goes through fine, but the POST request through my app results in a 302 Object not found type of error. I used fiddler2 to see the differences in the headers (both the header being sent and the response), and although there are minor
differences, I can't see anything obvious which might cause a major problem
I have attached the two responses to this post just for your reference
Internet Explorer POST and RESPONSE
POST http://portal.kmittal.com/uniquesig34acdc567b43b64f9e0fb44c575e2be4/uniquesig0/InternalSite/Validate.asp HTTP/1.1
Host: portal.kmittal.com
Connection: keep-alive
Content-Length: 126
Cache-Control: max-age=0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Origin: http://portal.kmittal.com
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.94 Safari/537.36
Content-Type: application/x-www-form-urlencoded
Referer: http://portal.kmittal.com/uniquesig34acdc567b43b64f9e0fb44c575e2be4/uniquesig0/portalPortalHomePage/
Accept-Encoding: gzip,deflate,sdch
Accept-Language: en-GB,en-US;q=0.8,en;q=0.6
Cookie: ASPSESSIONIDCQRQRQRA=GCFPDAPDONFCHDLCPPHNGPIJ; uniquesigB149A8232171E3C30DB80F3DF71C094B004298D99D9EB84911D792DE89F362D6A1231C7973EE037347F0E4E5690C1A7A=GCFPDAPDONFCHDLCPPHNGPIJ; WhlPII=2; NLSessionCportal=R9ywg8urgu7FwlpKQ+Jqj54wOYe45EaSm4/z4rLgrJgD2OZjsgf7mW1ClEfBFmvrDqZxtSMNOuDUeiOugx1+2Z3zWIEl8rEtOVOVySfbdcgy3pObzl94+dCjEE5dOhbY;
WhlInstall=False; WhlST=234000; NLSessionCportal=R9ywg8urgu7FwlpKQ+Jqj54wOYe45EaSm4/z4rLgrJgD2OZjsgf7mW1ClEfBFmvrDqZxtSMNOuDUeiOugx1+2Z3zWIEl8rEtOVOVySfbdcgy3pObzl94+dCjEE5dOhbY
user_name=testuser&password=Password1&repository=ws2012-dc&language=en-US&site_name=portal&secure=0&resource_id=2&login_type=2
HTTP/1.1 200 OK
Cache-Control: private
Content-Length: 14607
Content-Type: text/html
Server: Microsoft-IIS/7.5
X-Powered-By: ASP.NET
Server: Microsoft-IIS/6.0
Set-cookie: NLSessionCportal=R9ywg8urgu7FwlpKQ+Jqj54wOYe45EaSm4/z4rLgrJgD2OZjsgf7mW1ClEfBFmvrDqZxtSMNOuDUeiOugx1+2Z3zWIEl8rEtOVOVySfbdcgy3pObzl94+dCjEE5dOhbY;path=/
X-Powered-By: ASP.NET
Date: Mon, 27 May 2013 11:23:25 GMT
<HTML>
<HEAD>
<title>Microsoft Forefront Unified Access Gateway - Logon Page</title>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
<LINK rel="STYLESHEET" type="text/css" href="/uniquesig34acdc567b43b64f9e0fb44c575e2be4/uniquesig0/InternalSite/css/template.css">
<script>
var bWhlClientComponents = isWhlClientComponents();
function isWhlClientComponents()
{
if ("1" == 2)
return true;
else
return false;
}
function postValidateInstall()
{
if (bWhlClientComponents)
Install('/internalsite/installxml.asp?stage=0&uninstall_lln=0&remove_lln=0&lln_mode=0&use_wio=0&site_name=portal&secure=0&force_lln=0')
}
var isPostValidate = true;
</script>
</HEAD>
<BODY height="100%" onload="postValidateInstall();RedirectToOrigUrl();">
<table id="mainTable" height="98%" width="100%" style="display:none" cellspacing="0" cellpadding="0">
<tr>
<td valign="middle">
<TABLE align="center" class="blueBorder" cellspacing="0" cellpadding="0">
<tr >
<td id="companyTD" width="100%" colspan="3" style="">
<span class="header1 header1pos">
Application and Network Access Portal
</span>
<table width="100%" cellpadding="0" cellspacing="0">
<tr>
<td width="32px">
<img src="/uniquesig34acdc567b43b64f9e0fb44c575e2be4/uniquesig0/InternalSite/images/headertopl.gif" align="absmiddle">
</td>
<td style="background-image: url('/uniquesig34acdc567b43b64f9e0fb44c575e2be4/uniquesig0/InternalSite/images/headertopm.gif'); background-repeat: repeat-x">
</td>
<td width="520px" style="background-image: url('/uniquesig34acdc567b43b64f9e0fb44c575e2be4/uniquesig0/InternalSite/images/headertopr.gif');">
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td width="100%" colspan="3" style="">
<span style="margin-">
</span>
<table width="100%" cellpadding="0" cellspacing="0">
<tr>
<td width="30px">
<img src="/uniquesig34acdc567b43b64f9e0fb44c575e2be4/uniquesig0/InternalSite/images/headerbottoml.gif" align="absmiddle">
</td>
<td style="background-image: url('/uniquesig34acdc567b43b64f9e0fb44c575e2be4/uniquesig0/InternalSite/images/headerbottomm.gif'); background-repeat: repeat-x">
</td>
<td width="30px" style="background-image: url('/uniquesig34acdc567b43b64f9e0fb44c575e2be4/uniquesig0/InternalSite/images/headerbottomr.gif');">
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td valign="top" class="contentleft">
</td>
<td class="internalTD">
<table height="100%" width="100%" cellspacing="0" cellpadding="0">
<span id="appletSpan"></span>
<tr>
<td v-align="top">
<TABLE id="loadingTable" height="100%" border="0" class="content" cellspacing="0" cellpadding="0">
<tr height="20%">
<td id="td1" valign="top">
<span align="left" id="msgSpan" class="blueBold"><nobr>Downloading Endpoint Component Manager...</nobr></span><br><br>
<table cellpadding="0" cellspacing="0" class="nopadding">
<tr>
<td id="progressTD">
<table class="progressBarFrame" cellpadding="0" cellspacing="0">
<tr>
<td id="progressBar1" class="progressBarLeft"> </td>
<td id="progressBar2" class="progressBarRight"> </td>
</tr>
</table>
</td>
<td> <label class="blueBold" id="percents"></label></td>
</tr>
</table>
</td>
<td valign="top" rowspan="2" align="left" id="securityWarningTD">
<img id="securityWarningImg" width="300px" height="144px"><br>
<span class="blueBold" valign="bottom" align="right">If this prompt appears<br>click Install to install the components.</span>
</td>
</tr>
<tr height="80%">
<td valign="top" id="td2" class="regText">
<br><br>
Please wait a few minutes for component downloads to complete.<br>Corporate policy might require components for site access.
</td>
</tr>
</TABLE>
<TABLE id="blockedPopupTable" height="100%" border="0" class="content" cellspacing="0" cellpadding="0" style="display:none">
<tr>
<td class="bottomText" style="font-weight: bold;" valign="top" height="20%">
Access to this site requires one or more additional applications to be launched. Automatic launching of the required applications was blocked by your browser, probably by a pop-up blocker.<br>
</td>
</tr>
<tr>
<td class="bottomText" style="font-weight: bold;" height="200px" valign="top">
<br>Click <a href="javascript:launchAfterBlock();">here</a> to launch the application and access the site.<br><br>
To access this site in the future, it is recommended that you disable pop-up blockers for this site.
</td>
</tr>
</TABLE>
</td>
</tr>
</table>
</td>
<td valign="top" class="contentright">
</td>
</tr>
<tr>
<TD width="100%" colspan="3" style="">
<span class="bottomText bottomTextPos">
© 2010 Microsoft Corporation. All rights reserved. <a href='javascript:alert('Microsoft Corporation licenses the software and services on this portal to you according to your Microsoft Unified Access
Gateway 2010 (the "software") license. You may not use this portal without a license for the software. Contact your IT administrator for the license terms.')'>Terms and Conditions.</a>
</span>
<table width="100%" cellpadding="0" cellspacing="0">
<tr>
<td width="47px">
<img src="/uniquesig34acdc567b43b64f9e0fb44c575e2be4/uniquesig0/InternalSite/images/footerbgl.gif" align="absmiddle">
</td>
<td style="background-image: url('/uniquesig34acdc567b43b64f9e0fb44c575e2be4/uniquesig0/InternalSite/images/footerbgm.gif'); background-repeat: repeat-x">
</td>
<td width="47px" style="background-image: url('/uniquesig34acdc567b43b64f9e0fb44c575e2be4/uniquesig0/InternalSite/images/footerbgr.gif');">
</td>
</tr>
</table>
</td>
</tr>
</TABLE>
</td>
</tr>
</TABLE>
<script>
//getting domain cookie path (for set and invalidate) before using install.js
sDomainCookieAttr = ""
sDomainCookieToRemove = ""
//domain without AAM, or shortname/IP - remove domain cookie%>
sDomainCookieToRemove = "Kmittal.com"
sLoginURL
= "";
sOrigURL
= "http://portal.kmittal.com/uniquesig34acdc567b43b64f9e0fb44c575e2be4/uniquesig0/portalPortalHomePage/";
</script>
<script language="JavaScript" src="/uniquesig34acdc567b43b64f9e0fb44c575e2be4/uniquesig0/InternalSite/scripts/install.js"></script>
<script language="JavaScript">
//init page messages
var WhlClientComponentsNotInstalledMsgTitle = "Install Forefront UAG client components:";
var WhlClientComponentsNotInstalledMsgDirections = "To install the components:<br>1. Right-click the Information Bar.<br>2. Select <b>Install This Add-On for All Users</b>, as follows:";
var WhlClientComponentsNotInstalledMsgNote = "To install the components, you must have administrator privileges on this device.<br>If you cannot see the Internet Explorer Information Bar, enable your browser is to allow download of ActiveX components."
var WhlClientComponentsNotInstalledMsgSkip = "To skip this installation and continue with limited functionality click here:";
var DownloadAndInstallWaitMsg = "Downloading Endpoint Component Manager...";
var FailedUpdatingMsg = "Component updates failed.";
var TransferToLoginMsg = "Redirecting to logon page...";
var stopStr = "Stop";
var stopProgressStr = "Stopping...";
var completedStr = "completed";
var continueStr = "Continue";
var WhlClientComponentsNotInstalledStatus = "Forefront UAG client components were not installed...";
var piiMsg = "To provide full site functionality, data collected from this device might include personal information.<br>Without this option, you can access this site with limited functionality.<br>Do you want to enable this option?";
var piiOption1 = "Enable and continue with full functionality";
var piiOption2 = "Continue with limited functionality";
var piiCheckbox = "Don't show me this message again";
var piiSubmit = "Continue";
var isSecure = "C"
if ("0" == "1")
var isSecure = "S"
var eGapCookieName = "NLSession" + isSecure + "portal"
var newWinVer = true;
if ("True" != "True")
newWinVer = false;
//install Endpoint Component Manager
if (bWhlClientComponents && getCookie("WhlInstall") != "False")
{
//Don't try to install on old Windows version
if ("True" != "True")
document.cookie = "WhlInstall=False; path=/;";
if (isNewDM() || !newWinVer)
WhlInstallComponentManager('');
else
WhlInstallComponentManager('');
}
function isNewDM()
{
var bNewDM = true;
try
{
testObj = new ActiveXObject("ComponentManager.Installer.2");
}
catch(e)
{
bNewDM = false;
}
return bNewDM;
}
//popup blocker launching function
function launchAfterBlock()
{
if (isPostValidate)
startAutoLaunch();
else if (isStartApp)
{
LaunchStartApp();
setPageView();
removeProgress();
setMessage("Launching applications...");
hideAppletLauncher();
//for the case when using !http application as initial application
setTimeout("document.getElementById('mainTable').style.display = 'none';", 3000);
}
}
function Install(sURL)
{
if (getCookie("WhlInstall") != "False")
{
var sAskBrowserRestart="You are about to install Forefront UAG client components. After installation all open browser windows will be closed, and the browser will restart. Do you want to proceed?";
var bPersistCookie="1";
//If not using authenitcation at all, or session is not authenticated yet, don't persist the cookie:
if ("-1" == "0" || "-1" == "0")
bPersistCookie="0";
//component manager checks for component updates
WhlUpdateComponents("NLSessionCportal=R9ywg8urgu7FwlpKQ+Jqj54wOYe45EaSm4/z4rLgrJgD2OZjsgf7mW1ClEfBFmvrDqZxtSMNOuDUeiOugx1+2Z3zWIEl8rEtOVOVySfbdcgy3pObzl94+dCjEE5dOhbY",sURL,sAskBrowserRestart,"portal","0", bPersistCookie,"1");
}
}
function getMessage(eNotify)
{
switch(eNotify)
{
case 1:
return("Downloading and extracting" + " ");
case 2:
return("Downloading and extracting" + " ");
case 8:
return("Installing" + " ");
}
}
var errorStr = "";
function getErrorMessage(eNotify)
{
switch(eNotify)
{
case 1:
return("The following component cannot be downloaded:" + " ");
case 2:
return("The following component cannot be extracted:" + " ");
case 4:
//Invalid file checksum
return("The following component cannot be installed:" + " ");
case 8:
return("The following component cannot be installed:" + " ");
case 16:
return("The following component cannot be registered:" + " ");
case 32:
return("File in use:" + " ");
case 64:
return("The client configuration file cannot be updated:" + " ");
default:
return "";
}
}
</script>
<SCRIPT FOR=whaleClientComponentManager EVENT="SetProgress(progress,bDownload)" LANGUAGE="JavaScript">
if (bWhlClientComponents)
setProgress(progress)
</SCRIPT>
<SCRIPT FOR=whaleClientComponentManager EVENT="FileNotification(compName, fileName, fileVer, eNotify)" LANGUAGE="JavaScript">
//var strFile = getMessage(eNotify) + compName + " (" + fileName + ")";
if (bWhlClientComponents)
{
var strFile = getMessage(eNotify) + "Forefront UAG client components...";
setMessage(strFile);
}
</SCRIPT>
<SCRIPT FOR=whaleClientComponentManager EVENT="FileError(compName, fileName, fileVer, eNotify)" LANGUAGE="JavaScript">
if (bWhlClientComponents)
{
if(eNotify!=32)
//32 = file in use error - don't show it...
{
errorStr += getErrorMessage(eNotify) + compName + " (" + fileName + ")\n";
}
}
</SCRIPT>
<script language="JavaScript">
function RedirectToOrigUrl()
{
if (getCookie("WhlScheduledLogoff") == "True")
document.cookie = "WhlScheduledLogoff=False; path=/;";
setPageView();
removeProgress();
setMessage("Successful log on");
showUI();
//used after finish launching applications (Java)
redirectUrl = "/InternalSite/RedirectToOrigURL.asp?site_name=portal&secure=0";
startAutoLaunch();
//RESOURCE_OPERATION_LOGIN - change the location just in case there is no java applet to run or no autolaunch applicatios
if (bWhlClientComponents || "0" == 0)
{
setMessage("Successful log on.<br>Redirecting to the site home page...");
if (document.images)
window.location.replace("/uniquesig34acdc567b43b64f9e0fb44c575e2be4/uniquesig0/InternalSite/RedirectToOrigURL.asp?site_name=portal&secure=0");
else
window.location.href = "/uniquesig34acdc567b43b64f9e0fb44c575e2be4/uniquesig0/InternalSite/RedirectToOrigURL.asp?site_name=portal&secure=0";
}
}
function startAutoLaunch()
{
var bError = false;
if ('' != '')
{
setMessage("Launching applications...");
hideAppletLauncher();
//in case we work with java, and java is disabled no need to launch applications
checkActiveX();
if (bWhlClientComponents)
{
}
else
{
//used after finish launching applications (Java)
redirectUrl = "/InternalSite/RedirectToOrigURL.asp?site_name=portal&secure=0";
if (navigator.javaEnabled() && "True" == "True")
{
;
}
else
{
alert("The following applications cannot be started because the browser does not allow Java applets to run:\nTo use these applications, configure the browser settings to enable Java.");
if (document.images)
window.location.replace("/uniquesig34acdc567b43b64f9e0fb44c575e2be4/uniquesig0/InternalSite/RedirectToOrigURL.asp?site_name=portal&secure=0");
else
window.location.href = "/uniquesig34acdc567b43b64f9e0fb44c575e2be4/uniquesig0/InternalSite/RedirectToOrigURL.asp?site_name=portal&secure=0";
bError = true;
}
}
}
if ('0' == '1' && !bError)
{
alert("The following applications cannot be launched:");
}
}
</script>
</BODY>
</HTML>
Application POST and RESPONSE
POST http://portal.kmittal.com/uniquesig34acdc567b43b64f9e0fb44c575e2be4/uniquesig0/InternalSite/Validate.asp HTTP/1.1
Content-Type: application/x-www-form-urlencoded
Host: portal.kmittal.com
Cookie: NLSessionCportal=y1cYOi5Rj/hfK8ezAZrXz+XEhPYXUN90P4GoJ4MffwqTTn4tQHUj8cVEKEJTTw6G+MFfsktnf5JbOsW7/ROWZ4TgcUgNdTQqrqic6X5u3xF2wjVSs0xvG2Wa7Txs053O
Content-Length: 111
Expect: 100-continue
user_name=testuser&password=Password1&repository=ws2012-dc&resource_id=2&login_type=8&site_name=portal&secure=0
HTTP/1.1 302 Object moved
Cache-Control: private
Content-Length: 220
Content-Type: text/html
Location: /uniquesig34acdc567b43b64f9e0fb44c575e2be4/uniquesig0/InternalSite/InternalError.asp?error_code=116
Server: Microsoft-IIS/7.5
X-Powered-By: ASP.NET
Set-Cookie: ASPSESSIONIDCQRQRQRA=MCFPDAPDKNLGDFNJGILGKECO; Path=/uniquesig34acdc567b43b64f9e0fb44c575e2be4/uniquesig0/
Set-Cookie: uniquesigB149A8232171E3C30DB80F3DF71C094B004298D99D9EB84911D792DE89F362D6A1231C7973EE037347F0E4E5690C1A7A=MCFPDAPDKNLGDFNJGILGKECO; Path=/
Server: Microsoft-IIS/6.0
Set-cookie: NLSessionCportal=y1cYOi5Rj/hfK8ezAZrXz+XEhPYXUN90P4GoJ4MffwqTTn4tQHUj8cVEKEJTTw6G+MFfsktnf5JbOsW7/ROWZ4TgcUgNdTQqrqic6X5u3xF2wjVSs0xvG2Wa7Txs053O;path=/
X-Powered-By: ASP.NET
Date: Mon, 27 May 2013 11:25:28 GMT
<head><title>Object moved</title></head>
<body><h1>Object Moved</h1>This object may be found <a HREF="/uniquesig34acdc567b43b64f9e0fb44c575e2be4/uniquesig0/InternalSite/InternalError.asp?error_code=116">here</a>.</body>