So I am writing a web application for use within my organization. The application requires that it know who the current user is. This is done by calling the Request.ServerVariables("AUTH_USER") function, which works great as long as 'Anonymous Access' is disabled (unchecked) and 'Integrated Windows Authentication' is enabled (checked) within IIS for this subweb.
Unfortunately by doing this I get an 'Access Denied' error when I hit the load method of the XML DOM.
Example code:
dim urlToXmlFile
urlToXmlFile = "http://currentwebserver/currentsubweb/nameofxml.xml"
dim xmlDom
set xmlDom = Server.CreateObject("MSXML2.DOMDocument")
xmlDom.async = false
xmlDom.load( urlToXmlFile ) ' <-- this is where I get the error!
I've looked everywhere and cannot find a solution. I should be able to load an XML file into the DOM regardless of the authentication method.
Any help would be appreciated. So far the only two solutions I can come up with are:
a) create a new subweb that JUST gets the current user name and somehow passes it back to my XML reading subweb.
b) open up security on the entire system to 'Everyone', which works but our IS department wouldn't care for that.
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Here was my original code, which cause the access denied error:
dim urlToXml
urlToXml = "http://someserver/somesomeweb/nameofxml.xml"
dim xmlDom
set xmlDom = Server.CreateObject("MSXML2.DOMDocument")
xmlDom.loadXML( urlToXml )
dim xsl
set xsl = Server.CreateObject("MSXML2.DOMDocument")
xsl.async = false
xsl.load(server.MapPath("somexsl.xsl"))
Response.Write( xmlDom.transformNode(xsl) )
xmlDom.save( server.MapPath("accounting/somexml.xml") )
Now, here is my new code thanks to thomask:
dim urlToXml
urlToXml = "http://someserver/somesomeweb/nameofxml.xml"
set http = CreateObject("MSXML2.ServerXMLHTTP.3.0")
http.Open "GET", urlToXml, false
http.Send()
dim xmlDom
set xmlDom = Server.CreateObject("MSXML2.DOMDocument")
xmlDom.loadXML( http.responseXML.xml )
dim xsl
set xsl = Server.CreateObject("MSXML2.DOMDocument")
xsl.async = false
xsl.load(server.MapPath("somexsl.xsl"))
Response.Write( xmlDom.transformNode(xsl) )
xmlDom.save( server.MapPath("newxml.xml") )
Again thank you very much thomask.