Email conversation
From | Doug Moskowitz |
To | Me |
Subject | XMLHttp Permission Denied |
Date | 28 October 2004 16:34 |
Here is the code…
/////////////////////////////////////////////////////////////////////
var url = 'http://my_site_with_basic_authentication.com';
// this site is my Windows 2000 IIS site with basic authentication
var myAuthentication = base64EncodedStr;
// this is a my user:password string converted to base 64
var xmlDocument = new ActiveXObject('Microsoft.XMLHTTP');
xmlDocument.open('GET',url, false);
xmlDocument.setRequestHeader('Authorization','Basic '+base64EncodedStr);
xmlDocument.send();
/////////////////////////////////////////////////////////////////////
Here is what happens…
If I run this from my IEV6.0 browser with a local page, it works fine
... BUT
If I run this from my IEV6.0 browser served page, I get a 'Permission
Denied' error.
Looking forward to your reply.
Doug Moskowitz
From | Me |
To | Doug Moskowitz |
Subject | Re: XMLHttp Permission Denied |
Date | 29 October 2004 9:25 |
Doug,
> var xmlDocument = new ActiveXObject('Microsoft.XMLHTTP');
Firstly, eew. Only IE? Oh well, I suppose if this is for personal use I
will let you off, but Mozilla/FireFox, Safari 1.2+ and Opera 7.6+ all all
do the same thing with:
var xmlDocument = new XMLHttpRequest();
My script shows you how to check which one to use:
http://www.howtocreate.co.uk/jslibs/importxml.js
> xmlDocument.open('GET',url, false);
Is this the line that produces the error?
> xmlDocument.setRequestHeader('Authorization','Basic '+base64EncodedStr);
or this one?
> xmlDocument.send();
or this one?
From the look of it, the problem is that you are not hosting it on the same
domain as the request is going to (same origin policy violation). IE is not
supposed to mind this, but it may do because of the authentication.
Alternatively, it may be that your IE security settings prevent that action
on that domain. You can check this by removing all security restrictions
for whatever security zone that domain is in.
Mark 'Tarquin' Wilton-Jones - author of http://www.howtocreate.co.uk/
From | Doug Moskowitz |
To | Me |
Subject | Re: XMLHttp Permission Denied |
Date | 31 October 2004 2:21 |
Thank you for your last response.
Well, I'm still banging my head against the wall trying to solve a n
XMLHttp persmission denied. I my last email, I was trying to use my
browser to authenticate on a server with basic authentication and
retrieve XML using XMLHTTP.
I have changed my strategy somewhat as follows:
1) The client browser (IE6) calls an ASP on an unprotected page (IIS 5).
2) The ASP authenticates on the server where the XML is, loads the XML
and passes the XML back to the client.
The client side code looks like this:
var xml = ActiveXObject('Microsoft.XMLHTTP');
var url = 'http://server1/getxml.asp/' + nameValuePairs;
xml.open('POST', url, false);
xml.send();
The ASP code (getXML.asp) looks like this:
<%
Response.Buffer = true;
Response.CacheControl = 'Private'; // have tried Public also
Repsonse.ContentType = 'text/xml';
var url = 'http://server2/databaseCGI/' + Response.QueryString();
var xml = Server.CreateObject('Msxml2.ServerXMLHTTP.4.0');
xml.open('GET','http://protectedsite/cgi', false, 'user', 'password');
xml.send();
Response.Write(xml.responseText);
Response.Flush();
%>
Server1 and Server2 reside on the same network.
Here is what happens:
THIS WORKS if am logged on the network where server1 and server2 reside!
This is an improvement from where I was...I had been getting a
"permission denied" when I was using the browser to directly
authenticate on server2, even when I was logged on the network.
BUT UNFORTUNATELY, if I'm not logged on the network, I get an 'access
denied' message. When I lower my browser security settings to 'none', I
don't get the 'access denied', but the XML never comes.
I have tried various versions of XML parsers, and I've tried
authenticating with setRequestHeader instead authenticating within the
open method. No change.
Any thoughts?
From | Doug Moskowitz |
To | Me |
Subject | Re: XMLHttp Permission Denied |
Date | 31 October 2004 18:21 |
Problem solved...had a local network IP address buried in my code which
was not accessible from the outside...thanks for you help.
How do I donate to your site?
From | Me |
To | Doug Moskowitz |
Subject | Re: XMLHttp Permission Denied |
Date | 1 November 2004 9:53 |
Doug,
Good to hear you got it solved.
No need for any donations but thanks for the offer. I have a good hosting
service run by a friend who doesn't charge much :)
Tarquin