Question

PHP .htaccess problem with IE7 and 8

Asked by: Jakibrown

Hi there
I am looking for some help with a problem, I have a very simple form on a webpage for a users name and password. Tthe form then goes to the small PHP script and then opens up the membership webpage.  This all works fine in FireFox, Crome, Opera and Safari but IE7 and IE8 just fail to work and I get an error page.  I think the problem is in line four of the PHP code, but I cannot fine a fix for it, can anyone help please?

Thank you for reading this post.

PHP Code
<?php 
$user=$_REQUEST['user']; 
$pass=$_REQUEST['pass']; 
header("Location: http://".$user.":".$pass."@www.mysite.co.uk/clients"); 
exit; 
?> 
 
On page form 
<!-- code starts here --> 
<form action="http://www.mysite.co.uk/login.php" method="post" id="thisform"> 
<fieldset> 
<p><label for="Username">Username:</label> <input type="text" name="user"></p> 
<p><label for="Password">Password:</label> <input type="password" name="pass"></p> 
<p><input type="submit" value="Login"></p> 
</fieldset> 
</form>

                                  
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:

Select allOpen in new window

This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.

Subscribe now for full access to Experts Exchange and get

Instant Access to this Solution

  • Plus...
  • 30 Day FREE access, no risk, no obligation
  • Collaborate with the world's top tech experts
  • Unlimited access to our exclusive solution database
  • Never be left without tech help again

Subscribe Now

Asked On
2009-02-15 at 08:32:18ID24144998
Topic

Data Manipulation

Participating Experts
2
Points
500
Comments
4

Trusted by hundreds of thousands everyday for fast, accurate and reliable tech support.

  • "The time we save is the biggest benefit of Experts Exchange to Warner Bros. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange." Mike Kapnisakis, Warner Bros.
  • "Our team likes having a resource that is more secure than just using Google and most experts using this service really know their stuff. It's nice to look here first versus using Google." Dayna Sellner, Lockheed Martin
  • "Anytime that I've been stumped with a problem, 9 out of 10 times Experts Exchange has either the accepted solution or an open discussion of the potential solution to the problem." Kenny Red, eBay Inc.

See what Experts Exchange can do for you.

Got a question?

We've got the answer.

Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.

Screenshot of Experts Exchange Knowledgebase

Need individual assistance?

Our experts are ready to help.

If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.

Screenshot of Experts Exchange Knowledgebase

Want to learn from the best?

Read articles from industry experts.

Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.

Screenshot of an Article

Working on a long term project?

Store your work and research.

Save solutions to your questions, answers you’ve discovered through searching plus helpful articles in your personal knowledgebase for easy future access.

Screenshot of Experts Exchange Knowledgebase

Access the answers to your technology questions today.

Subscribe Now

30-day free trial. Register in 60 seconds.

What Makes Experts Exchange Unique?

Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Trusted by the world's most respected brands.

image of each brand's logo

Faithfully serving IT professionals since 1996.

Experts Exchange Logo

Try it out and discover for yourself.

Subscribe Now

30-day free trial. Register in 60 seconds.

Related Solutions

  1. Small AJAX app works in Firefox & Opera, but not in IE6 …
    The attached test code works fine in Firefox and Opera. But in IE6 and IE7, a runtime error (unknown) is produced in: function stateChanged() on statement: document.getElementById("info").innerHTML=xmlHttp.responseText; when I click on the "Send Emails"...
  2. CSS issues in IE7, Fine with FF, Opera and Safari. Sug…
    The following script works with no problems (so far) in Firefox, Safari and Opera, but doesn't work properly in IE7. I don't know too much about CSS so any suggestions would be useful. Please check the page - http://www.skate.co.uk/New%20Admin/onescript.php - The drop down m...
  3. Marquee problem in IE7, but OK in Firefox - Opera.
    Hi, I've recently being tasked with maintaining our company website. OK I thought, easy,.NO experience AT ALL in HTML but I DO have 25 years programming databases in an engineering environment. It can't be THAT hard...... OK, OK you can all stop laughing now.... Adding a sc...
  4. IE7, Firefox, and AVG will not Connect in Vista, but Sa…
    Hello, Client has a laptop that will not connect to websites using IE7 or Firefox, also cannot run updates with AVG. I have tried several different connections with no luck. Safari however works great. She had Norton installed and I uninstalled it Still no connection. ...
  5. Works in Firefox and Safari but not in IE
    At this page you can see an upload form (in the right low corner) it doesn't work with IE7 I'm using this .js script file http://www.shauninman.com/archive/2007/09/10/styling_file_inputs_with_css_and_the_dom I'm already using different .css files for IE7, Firefox, Safari. ...

Free Tech Articles

  1. WARNING: 5 Reasons why you should NEVER fix a computer for free.
    It is in our nature to love the puzzle. We are obsessed. The lot of us. We love puzzles. We love the challenge. We thrive on finding the answer. We hate disarray. It bothers us deep in our soul. W...
  2. SCCM OSD Basic troubleshooting
    SCCM 2007 OSD is a fantastic way to deploy operating systems, however, like most things SCCM issues can sometimes be difficult to resolve due to the sheer volume of logs to sift through and the dispe...
  3. Migrate Small Business Server 2003 to Exchange 2010 and Windows 2008 R2
    This guide is intended to provide step by step instructions on how to migrate from Small Business Server 2003 to Windows 2008 R2 with Exchange 2010. For this migration to work you will need the fo...
  4. Create a Win7 Gadget
    This article shows you how to create a simple "Gadget" -- a sort of mini-application supported by Windows 7 and Vista. Gadgets can be dropped anywhere on the desktop to provide instant information, ...
  5. Outlook continually prompting for username and password
    There have been a lot of questions recently regarding Outlook prompting for a username and password whilst using Exchange 2007. There are a few reasons why this would happen and I will try to cover t...
  6. Backup Exchange 2010 Information Store using Windows Backup
    There seems to be quite a lot of confusion around the ability to backup Exchange 2010 using the built in Windows Backup feature. This stems from the omission of this feature prior to Exchange 2007 s...

Cloud Class Webinars

  1. Avoiding Bugs in Microsoft Access
    Alison Balter takes and in-depth look at avoiding bugs in Access. In this webinar you will learn about using the immediate window to debug your applications, invoking the debugger, using breakpoints to troubleshoot, stepping through code, setting the next statement to execute, ...
  2. Top 10 Best New Features in Visio 2010
    Scott Helmers gives live demonstrations of the top 10 new features in Visio 2010. This webinar will teach you how to create compelling diagrams by adding shapes to the page with a single click, linking the shapes in a diagram to data in Excel (or SQL Server, or SharePoint), ...
  3. IT Consultant Business Secrets Revealed
    Michael Munger, Experts Exchange tech pro and IT consultant, pulls back the curtain on his very successful businesses and answers question on every IT consultant and business owner should know about. He shares secrets on what he did to solve the 5 most common problems in IT, ...
  4. Disaster Recovery and Business Continuity
    Quest CTO, Mike Billon, gives an overview of the steps involved in building a dunamic disaster recovery plan. Through case studies and an examination of software/hardware tooles for monitoring and testing, you'll gain a better understandin of where you are, where you want ...
  5. Organize Your Visio Diagrams with Containers and Lists
    Scott Helmers uses cross functional flowcharts, wireframe diagrams, data graphic legends and seating charts to teach you: how to ustilize all three new structured diagram components in Visio 2010, the best practices for organizeing shapes in previous version of Visio, how to organize ...
  6. How to Us Objects, Properties, Events and Methods in Microsoft Access
    Alison Dalter gives an in-depbth look at objects, properties, events and methods in Microsoft Access. In this webinar you will learn about using the object browser, referring to objects, working with properties and methods, working with object variables, understanding the ...

Join the Community

Give a Little. Get a Lot.

Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.

Join the Community

Answers

 

by: JakibrownPosted on 2009-02-16 at 07:21:55ID: 23650507

I have discovered reading numerous web sites that Microsoft put in a fix to IE7 and IE8 which prevents "Location" from working within a PHP script. Where I think the code problem is is within this line of code below:

What I am looking to do is have a standard web page which contains a login and password which will then send  the information through to the .htaccess and .htpasswd files. This will stop username and password popup. The code in my original posting works perfectly in 4 other browsers: FF, Chrome, Opera and Safari.

If someone could help I would be extremely grateful.

We do not want to go down the route of MySQL because of the cost involved in maintaining a database with the internet provider that we are with.

header("Location: http://".$user.":".$pass."@www.mysite.co.uk/clients"); 

                                              
1:

Select allOpen in new window

 

by: drfreshPosted on 2009-02-16 at 17:17:25ID: 23655640

Microsoft changed their support for usernames and passwords in a URL with a security patch.  There are a few workarounds, however.  This example uses the XMLHTTP workaround to pre-authenticate, and then redirect the browser to the desired URL.

<?php
$user=$_REQUEST['user'];
$pass=$_REQUEST['pass'];
$url="http://".$user.":".$pass."@www.mysite.co.uk/clients";
echo '<html>';
echo '<head>';
?>
 
<TITLE>Interim Redirect Page</TITLE>
 
<script language="Javascript">
function DoIt() {
 
if ( window.ActiveXObject ) {
    // IE
	RedirectBrowser("<? echo $url; ?>");
}
else {
  // Firefox
  document.location="<? echo $url; ?>";
  
  
}
 
 
}
 
</SCRIPT>
 
 
 
 
 
<SCRIPT Language="JavaScript" RUNAT="Client">
 
 
	/*_____________________________________________________
 
	Name:		GetUrlWithCreds()
	Purpose:	retrieve a URL from a specified location
	            which is returned from a server in a header
	            value called "Redirect-Location"
	Param(in):  none
	_______________________________________________________
    */
	function GetUrlWithCreds() { 
		//store the URL for the resource that will return the URL that includes the Basic auth credentials below:
		sURL = "http://ServerA.q837104.info/SomePath/PageOfInterest.asp";
		//create the XMLHTTP object to retrieve the URL that has embedded creds
		oXMLHttp = new ActiveXObject("Microsoft.XMLHTTP");
		oXMLHttp.Open("GET", sURL, false);
		oXMLHttp.Send();
		if ( oXMLHttp.status == 200) {
			sURLwCreds = oXMLHttp.getResponseHeader("Redirect-Location");
		}
		else {
			sURLwCreds = "Error = redirect not received from:\n\t" + sURL;
			alert(sURLwCreds + "\nstatus code = " + oXMLHttp.status);
		}
		oXMLHttp = null;
		RedirectBrowser(sURLwCreds);
    }
    
    
	/*_____________________________________________________
 
	Name:		LoadPage()
	Purpose:	sets the location of the current window
	            to be the URL passed to this function
	Param(in):  UrlToReload - a valid URL
	_______________________________________________________
    */
    function LoadPage(UrlToReload) {
    	window.location.href=UrlToReload;
    }
    
    
	/*_____________________________________________________
 
	Name:		RedirectBrowser()
	Purpose:	sets the location of the current window
	            to be the URL passed to this function
	Param(in):  sUrlwCreds - a URL with credentials 
	                         embedded between the protocol
	                         and host sections
	_______________________________________________________
    */    
    function RedirectBrowser(sUrlwCreds) {
    	aCurrentUrl = new ParseURL(sUrlwCreds);
		for (i = 1 ; i < aCurrentUrl.length ; i++) {
			if (aCurrentUrl[i] == null) {
				aCurrentUrl[i] = "";
			}
		}
		sURLwoCreds = aCurrentUrl[1] + "://" + aCurrentUrl[4];
		if (aCurrentUrl[5].length > 1) {
			sURLwoCreds += ":" + aCurrentUrl[5];
		}
		sURLwoCreds += aCurrentUrl[6] + aCurrentUrl[7]; 
		if (aCurrentUrl[8].length > 1) {
			sURLwoCreds += "?" + aCurrentUrl[8];
		}
		if (aCurrentUrl[9].length > 1) {
			sURLwoCreds += "#" + aCurrentUrl[9];
		}
		oXMLHttp = new ActiveXObject("Microsoft.XMLHTTP");
		try {
			oXMLHttp.Open("GET", sURLwoCreds, false, aCurrentUrl[2], aCurrentUrl[3]);
			oXMLHttp.Send();
			if ( oXMLHttp.status == 200 ) {
				//if all goes well, WinInet should now be authenticated on destination site so
				//   setting the current window's URL to that site will not prompt for credentials
				LoadPage(sURLwoCreds);
			}
			else {
				alert("Error - an unexepected status code was returned: " + oXMLHttp.status);
			}
		}
		catch(ex) {
			document.body.innerHTML = ErrorGenerator(ex);
		}
    }
 
 
	/*_____________________________________________________
 
	Name:		GetCLSID()
	Purpose:	retrieve a CLSID for a registered component
	Parameter:  sProgID - string that is a ProgID for a
	                      given registered component on
	                      the local computer.
	_______________________________________________________
    */
    function GetCLSID(sProgID) {
		try {
			var oWshShell = new ActiveXObject("WScript.Shell");
			return oWshShell.RegRead("HKCR\\" + sProgID + "\\CLSID\\");
		}
		catch(ex) {
			return "<table bgcolor=\"lightgrey\" cellpadding=5><tr><td><font color=\"darkred\"><B>" + ex.name + "</B><BR>" + ex.number + " : " + ex.description + "</font></td></tr></table><BR><BR>unable to read registry using WshShell.RegRead";
		}
	}
	
	
	/*______________________________________________________
 
	Name:		GetInProcServer32()
	Purpose:	retrieve a DLL path for a registered 
	            component
	parameter:  sCLSID - string that is a CLSID for a
	                     given registered component on 
	                     the local computer.
    _______________________________________________________
    */
    function GetInProcServer32(sCLSID) {
		try {
			var oWshShell = new ActiveXObject("WScript.Shell");
			return oWshShell.RegRead("HKCR\\CLSID\\" + sCLSID + "\\InProcServer32\\");
		}
		catch(ex) {
			return "<table bgcolor=\"lightgrey\" cellpadding=5><tr><td><font color=\"darkred\"><B>" + ex.name + "</B><BR>" + ex.number + " : " + ex.description + "</font></td></tr></table><BR><BR>unable to read registry using WshShell.RegRead";
		}
	}
 
 
	/*______________________________________________________
 
	Name:		GetVersion()
	Purpose:	Retrieve file version from PE header
	Parameter:	none
	
	NOTE: a description of the RegExp object used in 
	      this function is provided below:
      		the following Regular Expression:
			    (?:(%(.*?)%))(?:(\\(?:[^\?]*?\\)*)([^\?]*?)$)
			will seperate the string:
			    %SystemRoot%\System32\Inetsrv\w3core.dll
			into the following array elements (all strings):
		       array[0] = %SystemRoot%\System32\Inetsrv\w3core.dll
		       array[1] = %SystemRoot%
		       array[2] = SystemRoot
		       array[3] = \System32\Inetsrv\
		       array[4] = w3core.dll
    _______________________________________________________
    */
	function GetVersion() {
		var sSysPath = "";
		//generate the Path to the DLL being used to call XMLHTTP
		try {
			sXmlDllPath = GetInProcServer32(GetCLSID("Microsoft.XMLHTTP"));
			RegExp = /(?:(%(.*?)%))(?:(\\(?:[^\?]*?\\)*)([^\?]*?)$)/;
			if ( RegExp.test(sXmlDllPath) ) {
				arDllPath = RegExp.exec(sXmlDllPath);
				var oWSH;
				oWSH = new ActiveXObject("WScript.Shell");
				sSysPath = oWSH.Environment("PROCESS").Item(arDllPath[2]) + arDllPath[3] + arDllPath[4];
			}
			else {
				sSysPath = sXmlDllPath;
			}
		} 
		catch(e) {
			//return e.number + " - " + e.description + "\n\nWScript.Shell is needed to get DLL versions";
			document.body.innerHTML = ErrorGenerator(e);
		}
		// get the version of the file
		try {
			var oFSO;
			oFSO = new ActiveXObject("Scripting.FileSystemObject");
			arrReturned = new Array(2);
			arrReturned[0] = arDllPath[4];
			arrReturned[1] = oFSO.getFileVersion(sSysPath);
			return arrReturned;
		}
		catch(e) {
			//return e.number + " - " + e.description + "\n\nScripting.FileSystemObject is needed to get DLL versions";
			document.body.innerHTML = ErrorGenerator(e);
		}
	}
	
	
	/*_____________________________________________________
 
	Name:		ParseURL()
	Purpose:	Retrieve file version from PE header
	Parameter:	sURL: string that has is a URL in the
	            format specified in the details section
	            below.
    Return:     Array with URL parts
	                
    This function uses JavaScript's regular expression object to parse the
    URL passed to it, and return the parts of the URL in array elements.
 
      --------------------------------------------------------------------
      NOTE: URL canonicalization is a non-trivial task and this simplified 
            sample does not account for URL escaping or encoding where the
            address http://www.microsoft.com/security/ is equivalent to the
            address http%3A%2F%2Fwww%2Emicrosoft%2Ecom%2Fsecurity%2F 
      --------------------------------------------------------------------
 
    The proper format of the URL that should be passed to this function is:
		
      protocol://username:password@host:port/path/file?querystring#mappath
		   
    and the elements of the array returned from this function are:
		
       [0] = sURL
       [1] = protocol
       [2] = username
       [3] = password
       [4] = host
       [5] = port
       [6] = path
       [7] = file
       [8] = querystring
       [9] = mappath
		
    any URL parts that are not specifically declared in sURL will return a
    a null value for their array element (i.e. if the string "www.msn.com"
    was passed to this function, then only elements [0] and [4] would have
    values; all other elements in the array would return null). 
 
    Regular Expression details:
    RegExp = /^
		(?:
			([a-zA-Z]+)\:\/\/			// protocol
		)?
		(
			?:([^\:^\@]*?)				// username
			(?:\:(.*?))?				// password
			\@
		)?
		(
			[a-zA-Z0-9\.\_\-]*?			// host
		)
		(?:
			\:([0-9]{1,100})			// port
		)?
		(?:								
			(\/(?:[^\?]*?\/)*)			// path
			([^\?]*?)?					// file
			(?:\?(.*?))?				// querystring
			(?:#(.*))?					// anchor
		)?
		$/;
    _______________________________________________________
    */    
    function ParseURL(sURL) {
		RegExp = /^(?:([a-zA-Z]+)\:\/\/)?(?:([^\:^\@]*?)(?:\:(.*?))?\@)?([a-zA-Z0-9\.\_\-]*?)(?:\:([0-9]{1,100}))?(?:(\/(?:[^\?]*?\/)*)([^\?]*?)?(?:\?(.*?))?(?:#(.*))?)?$/;
		aUrlParts = RegExp.exec(sURL);
		return aUrlParts;
	}
	
	
	/*______________________________________________________
 
	Name:		ShowNeedUpdate()
	Purpose:	inform the user they need to install an
	            updated version of MSXML from 832414 
	Parameter:	none
	
	NOTE: this sample was written at a time when 832414 had
	      the only fix to msxml?.dll that would allow 
	      credentials to be passed via the XMLHTTP.Open 
	      method, if the computer has a wininet.dll that 
	      ships with MS04-004 (KB 832894) or later (dated
	      January 2004 or later).  
	      
          Detection is based ont he following criteria:
             MSXML 2.5 SP3 | msxml.dll  | 8.0.xxxx.x
             MSXML 2.6 SP2 | msxml2.dll | 8.30.xxxx.x
             MSXML 3.0 SP2 | msxml3.dll | 8.20.xxxx.x
             MSXML 3.0 SP3 | msxml3.dll | 8.30.xxxx.x
             MSXML 3.0 SP4 | msxml3.dll | 8.40.xxxx.x
             MSXML 4.0 SP2 | msxml4.dll | 4.20.xxxx.x
    _______________________________________________________
    */	
    function ShowNeedUpdate() {
		try {
			arFileInfo = GetVersion();
			if ( isArray(arFileInfo) ) {
				switch (arFileInfo[0].toLowerCase()) {
					case "msxml.dll":
						if ( GetXMLVersion(arFileInfo[1]) == 8.0 ) {
							GenerateXMLDLLink(arFileInfo[0], arFileInfo[1], "http://download.microsoft.com/download/c/e/8/ce81bc31-1ecf-46a3-b840-2839415e34ad/KB832414_MSXML2.5_x86.exe");
						}
						else {
							GenerateXMLNotMatched(arFileInfo[0], arFileInfo[1]);
						}
						break;
					case "msxml2.dll":
						if ( GetXMLVersion(arFileInfo[1]) == 8.3 ) {
							GenerateXMLDLLink(arFileInfo[0], arFileInfo[1], "http://download.microsoft.com/download/1/0/e/10e23019-f7aa-4497-8e13-94ff06a08ce1/KB832414_MSXML2.6_x86.exe");
						}
						else {
							GenerateXMLNotMatched(arFileInfo[0], arFileInfo[1]);
						}
						break;
					case "msxml3.dll":
						
						if ( GetXMLVersion(arFileInfo[1]) == 8.2 ) {
							GenerateXMLDLLink(arFileInfo[0], arFileInfo[1], "http://download.microsoft.com/download/d/1/3/d139c2ad-6c6f-4d34-8db6-c44fe968227f/KB832414_MSXML3.0_x86.exe");
						}
						else if ( GetXMLVersion(arFileInfo[1]) == 8.3 ) {
							GenerateXMLDLLink(arFileInfo[0], arFileInfo[1], "http://download.microsoft.com/download/b/1/9/b191831f-9a19-4a42-8a71-b2b267b4c715/KB832414_MSXML3.0_x86.exe");
							alert("I didn't think I'd be here");
						}
						else if ( GetXMLVersion(arFileInfo[1]) == 8.4 ) {
							GenerateXMLDLLink(arFileInfo[0], arFileInfo[1], "http://download.microsoft.com/download/7/f/b/7fb9bddd-c56b-4ed6-b49b-b5e8718dd778/KB832414_MSXML3.0_x86.exe");
						}
						else {
							GenerateXMLNotMatched(arFileInfo[0], arFileInfo[1]);
						}
						break;
					case "msxml4.dll":
						if ( GetXMLVersion(arFileInfo[1]) == 4.2 ) {
							GenerateXMLDLLink(arFileInfo[0], arFileInfo[1], "http://download.microsoft.com/download/a/f/d/afdb1779-18d6-4fd8-bb86-bfbfca5acaee/KB832414_MSXML4.0_x86.exe");
						}
						else {
							GenerateXMLNotMatched(arFileInfo[0], arFileInfo[1]);
						}
						break;
					default:
						GenerateXMLNotMatched(arFileInfo[0], arFileInfo[1]);
						break;
				}
			}
		}
		catch(ex) {
			document.body.innerHTML = ErrorGenerator(ex) ;
		}
	}
 
 
	/*_____________________________________________________
 
	Name:		GenerateXMLDLLink()
	Purpose:	display location for XML download
	Param[in]:	sDLLName - name of MSXML DLL found 
	            sDLLVersion - version of MSXML DLL 
	            sUpdateLink - URL to download update from
	_______________________________________________________
    */		
	function GenerateXMLDLLink(sDLLName, sDLLVersion, sUpdateLink) {
		sMessage  = "The following file is registered to load when <code>Microsoft.XMLHTTP</code> is instantiated on your computer:<BR><BR>";
		sMessage += "<table><tr><td>&nbsp;&nbsp;&nbsp;</td><td><table border=1><tr><th>module</th><th>version</th></tr><tr><td>" + sDLLName + "</td><td>" + sDLLVersion + "</td></tr></table></td></tr></table><BR>";
		sMessage += "To download the updated version of this module, click <a href=\"" + sUpdateLink + "\">here</a> and then select Open<BR><BR><BR><BR>";
		sMessage += "For more information about this update, see the article below:<BR><BR>";
		sMessage += "&nbsp;&nbsp;&nbsp;832414 XMLHTTP call fails for URLs with embedded user credentials<BR>";
		sMessage += "&nbsp;&nbsp;&nbsp;<a href=\"http://support.microsoft.com/?id=832414\">http://support.microsoft.com/?id=832414</a>";
		document.body.innerHTML = sMessage;
    }
    
    
	/*_____________________________________________________
 
	Name:		GenerateXMLNotMatched()
	Purpose:	display location for XML download
	Param[in]:	sDLLName - name of MSXML DLL found 
	            sDLLVersion - version of MSXML DLL 
	_______________________________________________________
    */		
    function GenerateXMLNotMatched(sDLLName, sDLLVersion) {
		sMessage  = "The following file is registered to load when <code>Microsoft.XMLHTTP</code> is instantiated on your computer:<BR><BR>";
		sMessage += "<table><tr><td>&nbsp;&nbsp;&nbsp;</td><td><table border=1><tr><th>module</th><th>version</th></tr><tr><td>" + sDLLName + "</td><td>" + sDLLVersion + "</td></tr></table></td></tr></table><BR>";
		sMessage += "Unfortunately this does not match any of the supported versions of MSXML that were patched following the release of MS04-004.  This message can also occur if you have a version newer than one of the following:<BR>";
		sMessage += "<table><tr><td>&nbsp;&nbsp;&nbsp;</td><td><table border=1><tr><th>module</th><th>version</th><th>product</th></tr>";
		sMessage += "   <tr><td>msxml.dll</td><td>8.0.7002.0</td><td>MSXML 2.5 SP3</td></tr>"
		sMessage += "   <tr><td>msxml2.dll</td><td>8.30.9528.0</td><td>MSXML 2.6 SP2</td></tr>"
		sMessage += "   <tr><td>msxml3.dll</td><td>8.20.9823.0</td><td>MSXML 3.0 SP2</td></tr>"
		sMessage += "   <tr><td>msxml3.dll</td><td>8.30.9929.0</td><td>MSXML 3.0 SP3</td></tr>"
		sMessage += "   <tr><td>msxml3.dll</td><td>8.40.9509.0</td><td>MSXML 3.0 SP4</td></tr>"
		sMessage += "   <tr><td>msxml4.dll</td><td>4.20.9821.0</td><td>MSXML 4.0 SP2</td></tr>"
		sMessage += "</table></td></tr></table><BR>";
		sMessage += "For more information about the patches, see the article below:<BR><BR>";
		sMessage += "&nbsp;&nbsp;&nbsp;832414 XMLHTTP call fails for URLs with embedded user credentials<BR>";
		sMessage += "&nbsp;&nbsp;&nbsp;<a href=\"http://support.microsoft.com/?id=832414\">http://support.microsoft.com/?id=832414</a>";
		document.body.innerHTML = sMessage;
    }
 
 
	/*_____________________________________________________
 
	Name:		GetXMLVersion()
	Purpose:	determine if object passed in is an array
	Param[in]:	sDLLVersion - full version string of DLL
	_______________________________________________________
    */		
	function GetXMLVersion(sDLLVersion) {
		fltDLLVer = parseFloat(sDLLVersion.slice(0,3));
		if ( isNaN( fltDLLVer ) ) {
			return 0;
		}
		else {
			return fltDLLVer;
		}
	}
 
	/*_____________________________________________________
 
	Name:		isArray()
	Purpose:	determine if object passed in is an array
	Param[in]:	obj - an object
	_______________________________________________________
    */		
	function isArray(obj) {
		intArrayFound = -1;
		try {
			intArrayFound = obj.constructor.toString().indexOf("Array");
			if ( intArrayFound != -1)
				return true;
			else
				return false;
			
		}
		catch (ex) {}
	}
		
	
	/*_____________________________________________________
 
	Name:		ErrorGenerator()
	Purpose:	generate detailed output when errors occur
	Param[in]:	ex - an error object
	_______________________________________________________
    */		
	function ErrorGenerator(ex) { 
		switch(ex.number) {
			case -2146827859:   //occurs when unsafe ActiveX components try to execute; probably from Registry read with WScript
			    sError = "<table bgcolor=\"lightgrey\" cellpadding=5><tr><td><font color=\"darkred\"><B>" + ex.name + "</B><BR>" + ex.number + " : " + ex.description + "</font></td></tr></table>";
			    sError += "<BR><BR>Automatic detection of your XML version requires that you click the <code>Yes</code> button on the diaolog with the message <code>An ActiveX control on this page might be unsafe to interact with other parts of the page.  Do you want to allow this interaction?</code><BR><BR>To automatically detect the version of XML you are running, click <a href=JavaScript:history.go(0)>here</a>, then click <code>Yes</code> in the popup dialog";
				sError += "<BR><BR><HR><BR>If you cannot click the <code>Yes</code> button to automatically detect the installed version of MSXML, you can manually determine which version of the required patch for this system (the patch is specific to the version and service pack level of MSXML installed on the computer), follow the steps below:";
				sError += "<ol>" ;
				sError += "   <li>open the Windows Explorer</li>";
				sError += "   <li>Navigate to the \Windows\System32</li>";
				sError += "   <li>right click on the file msxml?.dll</li>";
				sError += "   <li>select Properties</li>";
				sError += "   <li>click the Version tab</li>" ;
				sError += "   <li>note the version number of the file (supported versions of MSXML are listed below):</li>" 
				sError += "      <ul>";
				sError += "          <li>MSXML 2.5 SP3 | msxml.dll | 8.0.xxxx.x</li>";
				sError += "          <li>MSXML 2.6 SP2 | msxml2.dll | 8.30.xxxx.x</li>";
				sError += "          <li>MSXML 3.0 SP2 | msxml3.dll | 8.30.xxxx.x</li>";
				sError += "          <li>MSXML 3.0 SP3 | msxml3.dll | 8.30.xxxx.x</li>";
				sError += "          <li>MSXML 3.0 SP4 | msxml3.dll | 8.40.xxxx.x</li>";
				sError += "          <li>MSXML 4.0 SP2 | msxml4.dll | 8.20.xxxx.x</li>";
				sError += "      </ul>";
				sError += "</ol>" ;
				break;
			case -2146828218:  //occurs when trying to use a component on a page in an untrusted zone (in this case XMLHTTP) to connect to a URL different than the current site
				aUrlForThisPage = ParseURL(document.URL);
				sError = "<table bgcolor=\"lightgrey\" cellpadding=5><tr><td><font color=\"darkred\"><B>" + ex.name + "</B><BR>" + ex.number + " : " + ex.description + "</font></td></tr></table>";
				sError += "<BR><BR>Due to a recent security update, this site now requires user's to explicitely trust the site to maintain continued functionality.  To add this trust, follow the steps below:<BR><BR>";
				sError += "<ol>" ;
				sError += "   <li>from the menu in this window, select <code>Tools | Internet Options</code></li>" ;
				sError += "   <li>select the <code>Security</code> tab</li>" ;
				sError += "   <li>select the <code>Trusted sites</code> icon</li>" ;
				sError += "   <li>click <code>Sites</code> button</li>" ;
				sError += "   <li>in the box labeled <code>Add this Web site to the zone</code>, enter the text: <font color=blue>" + aUrlForThisPage[4] + "</font></li>" ;
				sError += "   <li>click the <code>Add</code> button</li>" ;
				sError += "   <li>click the <code>Close</code> button</li>" ;
				sError += "   <li>click the <code>Custom Level</code> button</li>" ;
				sError += "   <li>locate the \'Miscellaneous | Access data sources across domains\' section</li>" ;
				sError += "   <li>click the <code>Enable</code> button under the \'Access data sources across domains\' section</li>" ;
				sError += "   <li>click the <code>OK</code> button to close the \'Security Settings\' dialog</li>" ;
				sError += "   <li>click the <code>OK</code> button to close the \'Internet Options\' dialog</li>" ;
				sError += "   <li>click <a href=JavaScript:history.go(0)>here</a> once all other steps are complete</li>";
				sError += "</ol>" ;
				sError += "<br><br><br><b>Note:</b> these steps rely on the default configuration of \'Access data sources across domains\' being enabled in the \'Trusted sites\' zone.  For more information on this see the article:";
				sError += "<br><br>&nbsp;&nbsp;&nbsp;182569 - Description of Internet Explorer Security Zones Registry Entries";
				sError += "<br>&nbsp;&nbsp;&nbsp;&nbsp;<a href=\"http://support.microsoft.com/?id=182569\">http://support.microsoft.com/?id=832414</a>";
				break;
			case -2147221020:  //'Invalid Syntax' error; occurs when Q832414 or later version of msxml?.dll has been called
				
				sError = "<table bgcolor=\"lightgrey\" cellpadding=5><tr><td><font color=\"darkred\"><B>" + ex.name + "</B><BR>" + ex.number + " : " + ex.description + "</font></td></tr></table>";
				sError += "<BR><BR>Due to a recent security update, this site now requires user's to install the critical update Q832414.<BR><BR>";
				sError += "Click <a href=JavaScript:ShowNeedUpdate()>here</a> to automatically detect the version of the update you need to install to use this site.<BR>"
				sError += "If you choose to manually install the update, you will need to determine the correct version for your system and download the update from the article below:<BR><BR>";
				sError += "<br><br>&nbsp;&nbsp;&nbsp;832414 - XMLHTTP call fails for URLs with embedded user credentials";
				sError += "<br>&nbsp;&nbsp;&nbsp;&nbsp;<a href=\"http://support.microsoft.com/?id=832414\">http://support.microsoft.com/?id=832414</a><BR><BR>";
				sError += "To determine which version of the patch is required (the patch is specific to the version and service pack level of MSXML installed on the computer), follow the steps below:";
				sError += "<ol>" ;
				sError += "   <li>open the Windows Explorer</li>";
				sError += "   <li>Navigate to the \Windows\System</li>";
				sError += "   <li>right click on the file msxml?.dll</li>";
				sError += "   <li>select Properties</li>";
				sError += "   <li>click the Version tab</li>" ;
				sError += "   <li>note the version number of the file (supported versions of MSXML are listed below):</li>" 
				sError += "      <ul>";
				sError += "          <li>MSXML 2.5 SP3 | msxml.dll | 8.0.xxxx.x</li>";
				sError += "          <li>MSXML 2.6 SP2 | msxml2.dll | 8.30.xxxx.x</li>";
				sError += "          <li>MSXML 3.0 SP2 | msxml3.dll | 8.30.xxxx.x</li>";
				sError += "          <li>MSXML 3.0 SP3 | msxml3.dll | 8.30.xxxx.x</li>";
				sError += "          <li>MSXML 3.0 SP4 | msxml3.dll | 8.40.xxxx.x</li>";
				sError += "          <li>MSXML 4.0 SP2 | msxml4.dll | 8.20.xxxx.x</li>";
				sError += "      </ul>";
				sError += "</ol>" ;
				break;
			/*
			case null:	
				sError = "<table bgcolor=\"lightgrey\" cellpadding=5><tr><td><font color=\"darkred\"><B>" + ex.name + "</B><BR>" + ex.number + " : " + ex.description + "</font></td></tr></table>";
				sError += "<BR><BR>Due to a recent security update, this site now requires user's to install the critical update Q832414.<BR><BR>To manually install the update, download the update from the article below:<BR><BR>";
				sError += "<br><br>&nbsp;&nbsp;&nbsp;832414 - XMLHTTP call fails for URLs with embedded user credentials";
				sError += "<br>&nbsp;&nbsp;&nbsp;&nbsp;<a href=\"http://support.microsoft.com/?id=832414\">http://support.microsoft.com/?id=832414</a><BR><BR>";
				break;
			*/
			default:
				sError = "<table bgcolor=\"#C0C0C0\" cellpadding=5><tr><td><font color=\"darkred\"><B>" + ex.name + "</B>\n" + ex.number + " - " + ex.description + "</font></td></tr></table>";
				break;
			}
			return sError;
		}
 
</SCRIPT>
<STYLE TYPE="text/css">
	<!--
		BODY {font-family: Arial; font-size: 12px}
		TABLE {font-family: Arial; font-size: 12px}
	-->
</STYLE>
</HEAD>
<BODY onLoad="DoIt()"> 
Redirecting, please stand by...
</BODY>
</HTML>

                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141:
142:
143:
144:
145:
146:
147:
148:
149:
150:
151:
152:
153:
154:
155:
156:
157:
158:
159:
160:
161:
162:
163:
164:
165:
166:
167:
168:
169:
170:
171:
172:
173:
174:
175:
176:
177:
178:
179:
180:
181:
182:
183:
184:
185:
186:
187:
188:
189:
190:
191:
192:
193:
194:
195:
196:
197:
198:
199:
200:
201:
202:
203:
204:
205:
206:
207:
208:
209:
210:
211:
212:
213:
214:
215:
216:
217:
218:
219:
220:
221:
222:
223:
224:
225:
226:
227:
228:
229:
230:
231:
232:
233:
234:
235:
236:
237:
238:
239:
240:
241:
242:
243:
244:
245:
246:
247:
248:
249:
250:
251:
252:
253:
254:
255:
256:
257:
258:
259:
260:
261:
262:
263:
264:
265:
266:
267:
268:
269:
270:
271:
272:
273:
274:
275:
276:
277:
278:
279:
280:
281:
282:
283:
284:
285:
286:
287:
288:
289:
290:
291:
292:
293:
294:
295:
296:
297:
298:
299:
300:
301:
302:
303:
304:
305:
306:
307:
308:
309:
310:
311:
312:
313:
314:
315:
316:
317:
318:
319:
320:
321:
322:
323:
324:
325:
326:
327:
328:
329:
330:
331:
332:
333:
334:
335:
336:
337:
338:
339:
340:
341:
342:
343:
344:
345:
346:
347:
348:
349:
350:
351:
352:
353:
354:
355:
356:
357:
358:
359:
360:
361:
362:
363:
364:
365:
366:
367:
368:
369:
370:
371:
372:
373:
374:
375:
376:
377:
378:
379:
380:
381:
382:
383:
384:
385:
386:
387:
388:
389:
390:
391:
392:
393:
394:
395:
396:
397:
398:
399:
400:
401:
402:
403:
404:
405:
406:
407:
408:
409:
410:
411:
412:
413:
414:
415:
416:
417:
418:
419:
420:
421:
422:
423:
424:
425:
426:
427:
428:
429:
430:
431:
432:
433:
434:
435:
436:
437:
438:
439:
440:
441:
442:
443:
444:
445:
446:
447:
448:
449:
450:
451:
452:
453:
454:
455:
456:
457:
458:
459:
460:
461:
462:
463:
464:
465:
466:
467:
468:
469:
470:
471:
472:
473:
474:
475:
476:
477:
478:
479:
480:
481:
482:
483:
484:
485:
486:
487:
488:
489:
490:
491:
492:
493:
494:
495:
496:
497:
498:
499:
500:
501:
502:
503:
504:
505:
506:
507:
508:
509:
510:
511:
512:
513:
514:
515:
516:
517:
518:
519:
520:
521:
522:
523:
524:
525:
526:
527:
528:
529:
530:
531:
532:
533:
534:
535:
536:
537:
538:
539:
540:
541:
542:
543:
544:
545:
546:
547:
548:
549:
550:
551:
552:
553:
554:
555:
556:
557:
558:
559:
560:
561:
562:
563:
564:
565:

Select allOpen in new window

 

by: JakibrownPosted on 2009-02-17 at 01:16:08ID: 31547113

Extremely pleased with this solution, this was really an annoying problem and to have someone actually fix it when MS said it couldn't be done is really wonderful! THANK YOU! YOU ARE A STAR!

 

by: DelightendPosted on 2010-02-19 at 11:53:45ID: 26615166

drfresh,
 
The above example works like a dream in opera, chrome, firefox and IE 8 on windows xp, it also works perfectly on chrome, opera and firefox on windows 7. However on in IE8 on windows 7 it does not work. Can you please help me understand why? is there a different msxml dll that needs to be used for windows 7?

In windows 7 it appears that the username and password are being sent as variables in the url string like this:
http://website.com/homepage.aspx?user=user&pass=pass
Then the redirection does occur but the credentials are gone and I am once again prompted for them.

What am I missing?

Here is the code I am using:

<?php
$user=$_REQUEST['user'];
$pass=$_REQUEST['pass'];
$url="http://".$user.":".$pass."@website.com/homepage.aspx";
echo '<html>';
echo '<head>';
?>
 
<TITLE>Interim Redirect Page</TITLE>
 
<script language="Javascript">
function DoIt() {
 
if ( window.ActiveXObject ) {
    // IE
	RedirectBrowser("<? echo $url; ?>");
}
else {
  // Firefox
  $url = "http://user:pass@website.com/homepage.aspx";
  document.location="<? echo $url; ?>";
  
  
}
 
 
}
 
</SCRIPT>
 
 
 
 
 
<SCRIPT Language="JavaScript" RUNAT="Client">
 
 
	/*_____________________________________________________
 
	Name:		GetUrlWithCreds()
	Purpose:	retrieve a URL from a specified location
	            which is returned from a server in a header
	            value called "Redirect-Location"
	Param(in):  none
	_______________________________________________________
    */
	function GetUrlWithCreds() { 
		//store the URL for the resource that will return the URL that includes the Basic auth credentials below:
		sURL = "http://website.com/homepage.aspx";
		//create the XMLHTTP object to retrieve the URL that has embedded creds
		oXMLHttp = new ActiveXObject("Microsoft.XMLHTTP");
		oXMLHttp.Open("GET", sURL, false);
		oXMLHttp.Send();
		if ( oXMLHttp.status == 200) {
			sURLwCreds = oXMLHttp.getResponseHeader("Redirect-Location");
		}
		else {
			sURLwCreds = "Error = redirect not received from:\n\t" + sURL;
			alert(sURLwCreds + "\nstatus code = " + oXMLHttp.status);
		}
		oXMLHttp = null;
		RedirectBrowser(sURLwCreds);
    }
    
    
	/*_____________________________________________________
 
	Name:		LoadPage()
	Purpose:	sets the location of the current window
	            to be the URL passed to this function
	Param(in):  UrlToReload - a valid URL
	_______________________________________________________
    */
    function LoadPage(UrlToReload) {
    	window.location.href=UrlToReload;
    }
    
    
	/*_____________________________________________________
 
	Name:		RedirectBrowser()
	Purpose:	sets the location of the current window
	            to be the URL passed to this function
	Param(in):  sUrlwCreds - a URL with credentials 
	                         embedded between the protocol
	                         and host sections
	_______________________________________________________
    */    
    function RedirectBrowser(sUrlwCreds) {
    	aCurrentUrl = new ParseURL(sUrlwCreds);
		for (i = 1 ; i < aCurrentUrl.length ; i++) {
			if (aCurrentUrl[i] == null) {
				aCurrentUrl[i] = "";
			}
		}
		sURLwoCreds = aCurrentUrl[1] + "://" + aCurrentUrl[4];
		if (aCurrentUrl[5].length > 1) {
			sURLwoCreds += ":" + aCurrentUrl[5];
		}
		sURLwoCreds += aCurrentUrl[6] + aCurrentUrl[7]; 
		if (aCurrentUrl[8].length > 1) {
			sURLwoCreds += "?" + aCurrentUrl[8];
		}
		if (aCurrentUrl[9].length > 1) {
			sURLwoCreds += "#" + aCurrentUrl[9];
		}
		oXMLHttp = new ActiveXObject("Microsoft.XMLHTTP");
		try {
			oXMLHttp.Open("GET", sURLwoCreds, false, aCurrentUrl[2], aCurrentUrl[3]);
			oXMLHttp.Send();
			if ( oXMLHttp.status == 200 ) {
				//if all goes well, WinInet should now be authenticated on destination site so
				//   setting the current window's URL to that site will not prompt for credentials
				LoadPage(sURLwoCreds);
			}
			else {
				alert("Error - an unexepected status code was returned: " + oXMLHttp.status);
			}
		}
		catch(ex) {
			document.body.innerHTML = ErrorGenerator(ex);
		}
    }
 
 
	/*_____________________________________________________
 
	Name:		GetCLSID()
	Purpose:	retrieve a CLSID for a registered component
	Parameter:  sProgID - string that is a ProgID for a
	                      given registered component on
	                      the local computer.
	_______________________________________________________
    */
    function GetCLSID(sProgID) {
		try {
			var oWshShell = new ActiveXObject("WScript.Shell");
			return oWshShell.RegRead("HKCR\\" + sProgID + "\\CLSID\\");
		}
		catch(ex) {
			return "<table bgcolor=\"lightgrey\" cellpadding=5><tr><td><font color=\"darkred\"><B>" + ex.name + "</B><BR>" + ex.number + " : " + ex.description + "</font></td></tr></table><BR><BR>unable to read registry using WshShell.RegRead";
		}
	}
	
	
	/*______________________________________________________
 
	Name:		GetInProcServer32()
	Purpose:	retrieve a DLL path for a registered 
	            component
	parameter:  sCLSID - string that is a CLSID for a
	                     given registered component on 
	                     the local computer.
    _______________________________________________________
    */
    function GetInProcServer32(sCLSID) {
		try {
			var oWshShell = new ActiveXObject("WScript.Shell");
			return oWshShell.RegRead("HKCR\\CLSID\\" + sCLSID + "\\InProcServer32\\");
		}
		catch(ex) {
			return "<table bgcolor=\"lightgrey\" cellpadding=5><tr><td><font color=\"darkred\"><B>" + ex.name + "</B><BR>" + ex.number + " : " + ex.description + "</font></td></tr></table><BR><BR>unable to read registry using WshShell.RegRead";
		}
	}
 
 
	/*______________________________________________________
 
	Name:		GetVersion()
	Purpose:	Retrieve file version from PE header
	Parameter:	none
	
	NOTE: a description of the RegExp object used in 
	      this function is provided below:
      		the following Regular Expression:
			    (?:(%(.*?)%))(?:(\\(?:[^\?]*?\\)*)([^\?]*?)$)
			will seperate the string:
			    %SystemRoot%\System32\Inetsrv\w3core.dll
			into the following array elements (all strings):
		       array[0] = %SystemRoot%\System32\Inetsrv\w3core.dll
		       array[1] = %SystemRoot%
		       array[2] = SystemRoot
		       array[3] = \System32\Inetsrv\
		       array[4] = w3core.dll
    _______________________________________________________
    */
	function GetVersion() {
		var sSysPath = "";
		//generate the Path to the DLL being used to call XMLHTTP
		try {
			sXmlDllPath = GetInProcServer32(GetCLSID("Microsoft.XMLHTTP"));
			RegExp = /(?:(%(.*?)%))(?:(\\(?:[^\?]*?\\)*)([^\?]*?)$)/;
			if ( RegExp.test(sXmlDllPath) ) {
				arDllPath = RegExp.exec(sXmlDllPath);
				var oWSH;
				oWSH = new ActiveXObject("WScript.Shell");
				sSysPath = oWSH.Environment("PROCESS").Item(arDllPath[2]) + arDllPath[3] + arDllPath[4];
			}
			else {
				sSysPath = sXmlDllPath;
			}
		} 
		catch(e) {
			//return e.number + " - " + e.description + "\n\nWScript.Shell is needed to get DLL versions";
			document.body.innerHTML = ErrorGenerator(e);
		}
		// get the version of the file
		try {
			var oFSO;
			oFSO = new ActiveXObject("Scripting.FileSystemObject");
			arrReturned = new Array(2);
			arrReturned[0] = arDllPath[4];
			arrReturned[1] = oFSO.getFileVersion(sSysPath);
			return arrReturned;
		}
		catch(e) {
			//return e.number + " - " + e.description + "\n\nScripting.FileSystemObject is needed to get DLL versions";
			document.body.innerHTML = ErrorGenerator(e);
		}
	}
	
	
	/*_____________________________________________________
 
	Name:		ParseURL()
	Purpose:	Retrieve file version from PE header
	Parameter:	sURL: string that has is a URL in the
	            format specified in the details section
	            below.
    Return:     Array with URL parts
	                
    This function uses JavaScript's regular expression object to parse the
    URL passed to it, and return the parts of the URL in array elements.
 
      --------------------------------------------------------------------
      NOTE: URL canonicalization is a non-trivial task and this simplified 
            sample does not account for URL escaping or encoding where the
            address http://www.microsoft.com/security/ is equivalent to the
            address http%3A%2F%2Fwww%2Emicrosoft%2Ecom%2Fsecurity%2F 
      --------------------------------------------------------------------
 
    The proper format of the URL that should be passed to this function is:
		
      protocol://username:password@host:port/path/file?querystring#mappath
		   
    and the elements of the array returned from this function are:
		
       [0] = sURL
       [1] = protocol
       [2] = username
       [3] = password
       [4] = host
       [5] = port
       [6] = path
       [7] = file
       [8] = querystring
       [9] = mappath
		
    any URL parts that are not specifically declared in sURL will return a
    a null value for their array element (i.e. if the string "www.msn.com"
    was passed to this function, then only elements [0] and [4] would have
    values; all other elements in the array would return null). 
 
    Regular Expression details:
    RegExp = /^
		(?:
			([a-zA-Z]+)\:\/\/			// protocol
		)?
		(
			?:([^\:^\@]*?)				// username
			(?:\:(.*?))?				// password
			\@
		)?
		(
			[a-zA-Z0-9\.\_\-]*?			// host
		)
		(?:
			\:([0-9]{1,100})			// port
		)?
		(?:								
			(\/(?:[^\?]*?\/)*)			// path
			([^\?]*?)?					// file
			(?:\?(.*?))?				// querystring
			(?:#(.*))?					// anchor
		)?
		$/;
    _______________________________________________________
    */    
    function ParseURL(sURL) {
		RegExp = /^(?:([a-zA-Z]+)\:\/\/)?(?:([^\:^\@]*?)(?:\:(.*?))?\@)?([a-zA-Z0-9\.\_\-]*?)(?:\:([0-9]{1,100}))?(?:(\/(?:[^\?]*?\/)*)([^\?]*?)?(?:\?(.*?))?(?:#(.*))?)?$/;
		aUrlParts = RegExp.exec(sURL);
		return aUrlParts;
	}
	
	
	/*______________________________________________________
 
	Name:		ShowNeedUpdate()
	Purpose:	inform the user they need to install an
	            updated version of MSXML from 832414 
	Parameter:	none
	
	NOTE: this sample was written at a time when 832414 had
	      the only fix to msxml?.dll that would allow 
	      credentials to be passed via the XMLHTTP.Open 
	      method, if the computer has a wininet.dll that 
	      ships with MS04-004 (KB 832894) or later (dated
	      January 2004 or later).  
	      
          Detection is based ont he following criteria:
             MSXML 2.5 SP3 | msxml.dll  | 8.0.xxxx.x
             MSXML 2.6 SP2 | msxml2.dll | 8.30.xxxx.x
             MSXML 3.0 SP2 | msxml3.dll | 8.20.xxxx.x
             MSXML 3.0 SP3 | msxml3.dll | 8.30.xxxx.x
             MSXML 3.0 SP4 | msxml3.dll | 8.40.xxxx.x
             MSXML 4.0 SP2 | msxml4.dll | 4.20.xxxx.x
    _______________________________________________________
    */	
    function ShowNeedUpdate() {
		try {
			arFileInfo = GetVersion();
			if ( isArray(arFileInfo) ) {
				switch (arFileInfo[0].toLowerCase()) {
					case "msxml.dll":
						if ( GetXMLVersion(arFileInfo[1]) == 8.0 ) {
							GenerateXMLDLLink(arFileInfo[0], arFileInfo[1], "http://download.microsoft.com/download/c/e/8/ce81bc31-1ecf-46a3-b840-2839415e34ad/KB832414_MSXML2.5_x86.exe");
						}
						else {
							GenerateXMLNotMatched(arFileInfo[0], arFileInfo[1]);
						}
						break;
					case "msxml2.dll":
						if ( GetXMLVersion(arFileInfo[1]) == 8.3 ) {
							GenerateXMLDLLink(arFileInfo[0], arFileInfo[1], "http://download.microsoft.com/download/1/0/e/10e23019-f7aa-4497-8e13-94ff06a08ce1/KB832414_MSXML2.6_x86.exe");
						}
						else {
							GenerateXMLNotMatched(arFileInfo[0], arFileInfo[1]);
						}
						break;
					case "msxml3.dll":
						
						if ( GetXMLVersion(arFileInfo[1]) == 8.2 ) {
							GenerateXMLDLLink(arFileInfo[0], arFileInfo[1], "http://download.microsoft.com/download/d/1/3/d139c2ad-6c6f-4d34-8db6-c44fe968227f/KB832414_MSXML3.0_x86.exe");
						}
						else if ( GetXMLVersion(arFileInfo[1]) == 8.3 ) {
							GenerateXMLDLLink(arFileInfo[0], arFileInfo[1], "http://download.microsoft.com/download/b/1/9/b191831f-9a19-4a42-8a71-b2b267b4c715/KB832414_MSXML3.0_x86.exe");
							alert("I didn't think I'd be here");
						}
						else if ( GetXMLVersion(arFileInfo[1]) == 8.4 ) {
							GenerateXMLDLLink(arFileInfo[0], arFileInfo[1], "http://download.microsoft.com/download/7/f/b/7fb9bddd-c56b-4ed6-b49b-b5e8718dd778/KB832414_MSXML3.0_x86.exe");
						}
						else {
							GenerateXMLNotMatched(arFileInfo[0], arFileInfo[1]);
						}
						break;
					case "msxml4.dll":
						if ( GetXMLVersion(arFileInfo[1]) == 4.2 ) {
							GenerateXMLDLLink(arFileInfo[0], arFileInfo[1], "http://download.microsoft.com/download/a/f/d/afdb1779-18d6-4fd8-bb86-bfbfca5acaee/KB832414_MSXML4.0_x86.exe");
						}
						else {
							GenerateXMLNotMatched(arFileInfo[0], arFileInfo[1]);
						}
						break;
					default:
						GenerateXMLNotMatched(arFileInfo[0], arFileInfo[1]);
						break;
				}
			}
		}
		catch(ex) {
			document.body.innerHTML = ErrorGenerator(ex) ;
		}
	}
 
 
	/*_____________________________________________________
 
	Name:		GenerateXMLDLLink()
	Purpose:	display location for XML download
	Param[in]:	sDLLName - name of MSXML DLL found 
	            sDLLVersion - version of MSXML DLL 
	            sUpdateLink - URL to download update from
	_______________________________________________________
    */		
	function GenerateXMLDLLink(sDLLName, sDLLVersion, sUpdateLink) {
		sMessage  = "The following file is registered to load when <code>Microsoft.XMLHTTP</code> is instantiated on your computer:<BR><BR>";
		sMessage += "<table><tr><td>&nbsp;&nbsp;&nbsp;</td><td><table border=1><tr><th>module</th><th>version</th></tr><tr><td>" + sDLLName + "</td><td>" + sDLLVersion + "</td></tr></table></td></tr></table><BR>";
		sMessage += "To download the updated version of this module, click <a href=\"" + sUpdateLink + "\">here</a> and then select Open<BR><BR><BR><BR>";
		sMessage += "For more information about this update, see the article below:<BR><BR>";
		sMessage += "&nbsp;&nbsp;&nbsp;832414 XMLHTTP call fails for URLs with embedded user credentials<BR>";
		sMessage += "&nbsp;&nbsp;&nbsp;<a href=\"http://support.microsoft.com/?id=832414\">http://support.microsoft.com/?id=832414</a>";
		document.body.innerHTML = sMessage;
    }
    
    
	/*_____________________________________________________
 
	Name:		GenerateXMLNotMatched()
	Purpose:	display location for XML download
	Param[in]:	sDLLName - name of MSXML DLL found 
	            sDLLVersion - version of MSXML DLL 
	_______________________________________________________
    */		
    function GenerateXMLNotMatched(sDLLName, sDLLVersion) {
		sMessage  = "The following file is registered to load when <code>Microsoft.XMLHTTP</code> is instantiated on your computer:<BR><BR>";
		sMessage += "<table><tr><td>&nbsp;&nbsp;&nbsp;</td><td><table border=1><tr><th>module</th><th>version</th></tr><tr><td>" + sDLLName + "</td><td>" + sDLLVersion + "</td></tr></table></td></tr></table><BR>";
		sMessage += "Unfortunately this does not match any of the supported versions of MSXML that were patched following the release of MS04-004.  This message can also occur if you have a version newer than one of the following:<BR>";
		sMessage += "<table><tr><td>&nbsp;&nbsp;&nbsp;</td><td><table border=1><tr><th>module</th><th>version</th><th>product</th></tr>";
		sMessage += "   <tr><td>msxml.dll</td><td>8.0.7002.0</td><td>MSXML 2.5 SP3</td></tr>"
		sMessage += "   <tr><td>msxml2.dll</td><td>8.30.9528.0</td><td>MSXML 2.6 SP2</td></tr>"
		sMessage += "   <tr><td>msxml3.dll</td><td>8.20.9823.0</td><td>MSXML 3.0 SP2</td></tr>"
		sMessage += "   <tr><td>msxml3.dll</td><td>8.30.9929.0</td><td>MSXML 3.0 SP3</td></tr>"
		sMessage += "   <tr><td>msxml3.dll</td><td>8.40.9509.0</td><td>MSXML 3.0 SP4</td></tr>"
		sMessage += "   <tr><td>msxml4.dll</td><td>4.20.9821.0</td><td>MSXML 4.0 SP2</td></tr>"
		sMessage += "</table></td></tr></table><BR>";
		sMessage += "For more information about the patches, see the article below:<BR><BR>";
		sMessage += "&nbsp;&nbsp;&nbsp;832414 XMLHTTP call fails for URLs with embedded user credentials<BR>";
		sMessage += "&nbsp;&nbsp;&nbsp;<a href=\"http://support.microsoft.com/?id=832414\">http://support.microsoft.com/?id=832414</a>";
		document.body.innerHTML = sMessage;
    }
 
 
	/*_____________________________________________________
 
	Name:		GetXMLVersion()
	Purpose:	determine if object passed in is an array
	Param[in]:	sDLLVersion - full version string of DLL
	_______________________________________________________
    */		
	function GetXMLVersion(sDLLVersion) {
		fltDLLVer = parseFloat(sDLLVersion.slice(0,3));
		if ( isNaN( fltDLLVer ) ) {
			return 0;
		}
		else {
			return fltDLLVer;
		}
	}
 
	/*_____________________________________________________
 
	Name:		isArray()
	Purpose:	determine if object passed in is an array
	Param[in]:	obj - an object
	_______________________________________________________
    */		
	function isArray(obj) {
		intArrayFound = -1;
		try {
			intArrayFound = obj.constructor.toString().indexOf("Array");
			if ( intArrayFound != -1)
				return true;
			else
				return false;
			
		}
		catch (ex) {}
	}
		
	
	/*_____________________________________________________
 
	Name:		ErrorGenerator()
	Purpose:	generate detailed output when errors occur
	Param[in]:	ex - an error object
	_______________________________________________________
    */		
	function ErrorGenerator(ex) { 
		switch(ex.number) {
			case -2146827859:   //occurs when unsafe ActiveX components try to execute; probably from Registry read with WScript
			    sError = "<table bgcolor=\"lightgrey\" cellpadding=5><tr><td><font color=\"darkred\"><B>" + ex.name + "</B><BR>" + ex.number + " : " + ex.description + "</font></td></tr></table>";
			    sError += "<BR><BR>Automatic detection of your XML version requires that you click the <code>Yes</code> button on the diaolog with the message <code>An ActiveX control on this page might be unsafe to interact with other parts of the page.  Do you want to allow this interaction?</code><BR><BR>To automatically detect the version of XML you are running, click <a href=JavaScript:history.go(0)>here</a>, then click <code>Yes</code> in the popup dialog";
				sError += "<BR><BR><HR><BR>If you cannot click the <code>Yes</code> button to automatically detect the installed version of MSXML, you can manually determine which version of the required patch for this system (the patch is specific to the version and service pack level of MSXML installed on the computer), follow the steps below:";
				sError += "<ol>" ;
				sError += "   <li>open the Windows Explorer</li>";
				sError += "   <li>Navigate to the \Windows\System32</li>";
				sError += "   <li>right click on the file msxml?.dll</li>";
				sError += "   <li>select Properties</li>";
				sError += "   <li>click the Version tab</li>" ;
				sError += "   <li>note the version number of the file (supported versions of MSXML are listed below):</li>" 
				sError += "      <ul>";
				sError += "          <li>MSXML 2.5 SP3 | msxml.dll | 8.0.xxxx.x</li>";
				sError += "          <li>MSXML 2.6 SP2 | msxml2.dll | 8.30.xxxx.x</li>";
				sError += "          <li>MSXML 3.0 SP2 | msxml3.dll | 8.30.xxxx.x</li>";
				sError += "          <li>MSXML 3.0 SP3 | msxml3.dll | 8.30.xxxx.x</li>";
				sError += "          <li>MSXML 3.0 SP4 | msxml3.dll | 8.40.xxxx.x</li>";
				sError += "          <li>MSXML 4.0 SP2 | msxml4.dll | 8.20.xxxx.x</li>";
				sError += "      </ul>";
				sError += "</ol>" ;
				break;
			case -2146828218:  //occurs when trying to use a component on a page in an untrusted zone (in this case XMLHTTP) to connect to a URL different than the current site
				aUrlForThisPage = ParseURL(document.URL);
				sError = "<table bgcolor=\"lightgrey\" cellpadding=5><tr><td><font color=\"darkred\"><B>" + ex.name + "</B><BR>" + ex.number + " : " + ex.description + "</font></td></tr></table>";
				sError += "<BR><BR>Due to a recent security update, this site now requires user's to explicitely trust the site to maintain continued functionality.  To add this trust, follow the steps below:<BR><BR>";
				sError += "<ol>" ;
				sError += "   <li>from the menu in this window, select <code>Tools | Internet Options</code></li>" ;
				sError += "   <li>select the <code>Security</code> tab</li>" ;
				sError += "   <li>select the <code>Trusted sites</code> icon</li>" ;
				sError += "   <li>click <code>Sites</code> button</li>" ;
				sError += "   <li>in the box labeled <code>Add this Web site to the zone</code>, enter the text: <font color=blue>" + aUrlForThisPage[4] + "</font></li>" ;
				sError += "   <li>uncheck the box Require server verification (https)... below the list</li>" ;	
				sError += "   <li>click the <code>Add</code> button</li>" ;
				sError += "   <li>click the <code>Close</code> button</li>" ;
				sError += "   <li>click the <code>Custom Level</code> button</li>" ;
				sError += "   <li>locate the \'Miscellaneous | Access data sources across domains\' section</li>" ;
				sError += "   <li>click the <code>Enable</code> button under the \'Access data sources across domains\' section</li>" ;
				sError += "   <li>click the <code>OK</code> button to close the \'Security Settings\' dialog</li>" ;
				sError += "   <li>click the <code>OK</code> button to close the \'Internet Options\' dialog</li>" ;
				sError += "   <li>click <a href=JavaScript:history.go(0)>here</a> once all other steps are complete</li>";
				sError += "</ol>" ;
				sError += "<br><br><br><b>Note:</b> these steps rely on the default configuration of \'Access data sources across domains\' being enabled in the \'Trusted sites\' zone.  For more information on this see the article:";
				sError += "<br><br>&nbsp;&nbsp;&nbsp;182569 - Description of Internet Explorer Security Zones Registry Entries";
				sError += "<br>&nbsp;&nbsp;&nbsp;&nbsp;<a href=\"http://support.microsoft.com/?id=182569\">http://support.microsoft.com/?id=832414</a>";
				break;
			case -2147221020:  //'Invalid Syntax' error; occurs when Q832414 or later version of msxml?.dll has been called
				
				sError = "<table bgcolor=\"lightgrey\" cellpadding=5><tr><td><font color=\"darkred\"><B>" + ex.name + "</B><BR>" + ex.number + " : " + ex.description + "</font></td></tr></table>";
				sError += "<BR><BR>Due to a recent security update, this site now requires user's to install the critical update Q832414.<BR><BR>";
				sError += "Click <a href=JavaScript:ShowNeedUpdate()>here</a> to automatically detect the version of the update you need to install to use this site.<BR>"
				sError += "If you choose to manually install the update, you will need to determine the correct version for your system and download the update from the article below:<BR><BR>";
				sError += "<br><br>&nbsp;&nbsp;&nbsp;832414 - XMLHTTP call fails for URLs with embedded user credentials";
				sError += "<br>&nbsp;&nbsp;&nbsp;&nbsp;<a href=\"http://support.microsoft.com/?id=832414\">http://support.microsoft.com/?id=832414</a><BR><BR>";
				sError += "To determine which version of the patch is required (the patch is specific to the version and service pack level of MSXML installed on the computer), follow the steps below:";
				sError += "<ol>" ;
				sError += "   <li>open the Windows Explorer</li>";
				sError += "   <li>Navigate to the \Windows\System</li>";
				sError += "   <li>right click on the file msxml?.dll</li>";
				sError += "   <li>select Properties</li>";
				sError += "   <li>click the Version tab</li>" ;
				sError += "   <li>note the version number of the file (supported versions of MSXML are listed below):</li>" 
				sError += "      <ul>";
				sError += "          <li>MSXML 2.5 SP3 | msxml.dll | 8.0.xxxx.x</li>";
				sError += "          <li>MSXML 2.6 SP2 | msxml2.dll | 8.30.xxxx.x</li>";
				sError += "          <li>MSXML 3.0 SP2 | msxml3.dll | 8.30.xxxx.x</li>";
				sError += "          <li>MSXML 3.0 SP3 | msxml3.dll | 8.30.xxxx.x</li>";
				sError += "          <li>MSXML 3.0 SP4 | msxml3.dll | 8.40.xxxx.x</li>";
				sError += "          <li>MSXML 4.0 SP2 | msxml4.dll | 8.20.xxxx.x</li>";
				sError += "      </ul>";
				sError += "</ol>" ;
				break;
			/*
			case null:	
				sError = "<table bgcolor=\"lightgrey\" cellpadding=5><tr><td><font color=\"darkred\"><B>" + ex.name + "</B><BR>" + ex.number + " : " + ex.description + "</font></td></tr></table>";
				sError += "<BR><BR>Due to a recent security update, this site now requires user's to install the critical update Q832414.<BR><BR>To manually install the update, download the update from the article below:<BR><BR>";
				sError += "<br><br>&nbsp;&nbsp;&nbsp;832414 - XMLHTTP call fails for URLs with embedded user credentials";
				sError += "<br>&nbsp;&nbsp;&nbsp;&nbsp;<a href=\"http://support.microsoft.com/?id=832414\">http://support.microsoft.com/?id=832414</a><BR><BR>";
				break;
			*/
			default:
				sError = "<table bgcolor=\"#C0C0C0\" cellpadding=5><tr><td><font color=\"darkred\"><B>" + ex.name + "</B>\n" + ex.number + " - " + ex.description + "</font></td></tr></table>";
				break;
			}
			return sError;
		}
 
</SCRIPT>
<STYLE TYPE="text/css">
	<!--
		BODY {font-family: Arial; font-size: 12px}
		TABLE {font-family: Arial; font-size: 12px}
	-->
</STYLE>
</HEAD>
<BODY onLoad="DoIt()"> 
Redirecting, please stand by...
</BODY>
</HTML>
                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141:
142:
143:
144:
145:
146:
147:
148:
149:
150:
151:
152:
153:
154:
155:
156:
157:
158:
159:
160:
161:
162:
163:
164:
165:
166:
167:
168:
169:
170:
171:
172:
173:
174:
175:
176:
177:
178:
179:
180:
181:
182:
183:
184:
185:
186:
187:
188:
189:
190:
191:
192:
193:
194:
195:
196:
197:
198:
199:
200:
201:
202:
203:
204:
205:
206:
207:
208:
209:
210:
211:
212:
213:
214:
215:
216:
217:
218:
219:
220:
221:
222:
223:
224:
225:
226:
227:
228:
229:
230:
231:
232:
233:
234:
235:
236:
237:
238:
239:
240:
241:
242:
243:
244:
245:
246:
247:
248:
249:
250:
251:
252:
253:
254:
255:
256:
257:
258:
259:
260:
261:
262:
263:
264:
265:
266:
267:
268:
269:
270:
271:
272:
273:
274:
275:
276:
277:
278:
279:
280:
281:
282:
283:
284:
285:
286:
287:
288:
289:
290:
291:
292:
293:
294:
295:
296:
297:
298:
299:
300:
301:
302:
303:
304:
305:
306:
307:
308:
309:
310:
311:
312:
313:
314:
315:
316:
317:
318:
319:
320:
321:
322:
323:
324:
325:
326:
327:
328:
329:
330:
331:
332:
333:
334:
335:
336:
337:
338:
339:
340:
341:
342:
343:
344:
345:
346:
347:
348:
349:
350:
351:
352:
353:
354:
355:
356:
357:
358:
359:
360:
361:
362:
363:
364:
365:
366:
367:
368:
369:
370:
371:
372:
373:
374:
375:
376:
377:
378:
379:
380:
381:
382:
383:
384:
385:
386:
387:
388:
389:
390:
391:
392:
393:
394:
395:
396:
397:
398:
399:
400:
401:
402:
403:
404:
405:
406:
407:
408:
409:
410:
411:
412:
413:
414:
415:
416:
417:
418:
419:
420:
421:
422:
423:
424:
425:
426:
427:
428:
429:
430:
431:
432:
433:
434:
435:
436:
437:
438:
439:
440:
441:
442:
443:
444:
445:
446:
447:
448:
449:
450:
451:
452:
453:
454:
455:
456:
457:
458:
459:
460:
461:
462:
463:
464:
465:
466:
467:
468:
469:
470:
471:
472:
473:
474:
475:
476:
477:
478:
479:
480:
481:
482:
483:
484:
485:
486:
487:
488:
489:
490:
491:
492:
493:
494:
495:
496:
497:
498:
499:
500:
501:
502:
503:
504:
505:
506:
507:
508:
509:
510:
511:
512:
513:
514:
515:
516:
517:
518:
519:
520:
521:
522:
523:
524:
525:
526:
527:
528:
529:
530:
531:
532:
533:
534:
535:
536:
537:
538:
539:
540:
541:
542:
543:
544:
545:
546:
547:
548:
549:
550:
551:
552:
553:
554:
555:
556:
557:
558:
559:
560:
561:
562:
563:
564:
565:
566:
567:

Select allOpen in new window

20120131-EE-VQP-002

3 Ways to Join

30-Day Free Trial

The Experts

98% positive feedback on 31,087 answers since March 2000. angeliii is a Microsoft Most Valuable Professional for his work with MS SQL Server & Develoment.

He has also proven his knowledge of Visual Basic Programming, PHP Scripting and Oracle Databases.

The Experts

97% positive feedback on 10,752 answers since July 2000. lrmoore has more than 18 years experience in the networking industry.

The six-time Mircosoft MVPs specialties include firewalls, virtual private networking, and network management.

Testimonials

"...and excellent source for support... Kind of like having your very own IT dept." Electriciansnet

Testimonials

"I was apprehensive at signing up at first. However... it has already made my life as an IT administrator much easier." JaCrews

Testimonials

"WOW! You guys have great, active, and knowledgeable people on here." moore50

Business Clients

Business Clients

In the Press

"If you’ve got a question... Experts Exchange can supply an answer.”

In the Press

"...an invaluable aid for both IT professionals and those who require tech support."

In the Press

"where IT professionals provide quick answers on just about any topic"

Business Account Plans

Loading Advertisement...