I'm using VBA to send a GET request using either a WinHttpRequest
or an MSXML2.ServerXMLHTTP60
object (but I assume this would be the same even in a C# console app e.g.)
The GET
request is over an intranet connection and uses windows credentials - if the correct credentials are supplied then we get a login option, if not we just get 401.
As the same user on the same machine, I have different luck depending on location. At home, it runs fine but in the office it doesn't work. I checked the HEAD request to the same URL like so
Dim REQ As New MSXML2.ServerXMLHTTP60
Call REQ.Open("HEAD", "https://TargetCompanyWebSite.co.uk/")
Call REQ.Send
for the URL and I get this - this is the setup that works:
Cache-Control: private
Date: Tue, 01 Jun 2021 12:48:40 GMT
Content-Length: 5407
Content-Type: text/html; charset=utf-8
Server: Microsoft-IIS/7.5
Set-Cookie: ASP.NET_SessionId=abcdefghijklmnopqrstuvwxyz; path=/; HttpOnly
Persistent-Auth: true
X-Powered-By: ASP.NET
X-UA-Compatible: IE=Edge
however, in the office, where the connection doesn't work, I get:
Cache-Control: private
Date: Tue, 01 Jun 2021 12:52:24 GMT
Content-Length: 1293
Content-Type: text/html
Server: Microsoft-IIS/7.5
WWW-Authenticate: Negotiate
WWW-Authenticate: NTLM
X-Powered-By: ASP.NET
X-UA-Compatible: IE=Edge
If I use the site in a browser it works fine wherever I am, but I'm trying to figure out how to get this working as a .net
lib object (e.g. WinHttp.WinHttpRequest
or MSXML2.ServerXMLHTTP60
)
I'm finding things about WWW-Authenticate: Negotiate
but no straight forward answer on whether I can just set my own headers?