Technology Dribble

Another WordPress weblog about Technology

Archive for December, 2008

Accessing a Web Page Requiring NLTM Authentication Through ASP MSXML2.ServerXMLHTTP Object

Have you ever “scraped” web page contents using the following code:

<%
  Set xml = Server.CreateObject("MSXML2.ServerXMLHTTP")

  ' Opens the connection to the remote server.
  xml.Open "GET", "http://www.somedomain.com", False

  xml.Send
  v_response = xml.responseText
  response.write v_response
  Set xml = Nothing
%>

To your suprise, the web page content returned the following:


In order to access this page you must be using a browser which supports NTLM authentication. Currently, only Internet Explorer supports this

Well, this occurred because the page you accessed (http://www.somedomain.com based on the example above) requires NLTM authentication. In order to access the page successfully, you need to pass username and password credentials during the “GET” command. This can be achieved by modifying the code above to include the username and password:

<%
  Set xml = Server.CreateObject("MSXML2.ServerXMLHTTP")

  ' Opens the connection to the remote server.
  xml.Open "GET", "http://www.somedomain.com", "DOMAIN\user", "password"

  xml.Send
  v_response = xml.responseText
  response.write v_response
  Set xml = Nothing
%>

Make sure your replace “http://www.somedomain.com”, “DOMAIN\user” and “password” with values applicable to your process.

That’s it. Happy coding!

posted by admin in screen scrape and have No Comments