Using VBA to Download a File from a SAML Validated Website
I would like to create an excel vba plugin capable of downloading an excel file from an intranet website that is currently protected by SAML authentication.
If I try to download a file using Internet Explorer or Google Chrome, the file will automatically start downloading without any credentials, and I think this is because it uses some kind of Integrated Windows Authentication based on them.
If I try to load using a VBA object like winhttp.winhttprequest.5.1 I get some html page that I think starts SAML authentication (so I assume the winhttp.winhttprequest.5.1 object I used doesn't support SAML authentication).
Is there any easy way to do SAML authentication using VBA or do I need to manually code the authentication steps?
source to share
The problem is that while the various libraries redistributed with Windows / Office will keep track of HTTP and SSL for you, it's not easy to find one that does SAML..NET has Windows Communication Foundation (WCF) to use in VBA, but I don't know how it works with websites.
If you cannot get WCF to do SAML for you, the easiest way might be to automate Internet Explorer, since Internet Explorer already contains SAML functionality. Unfortunately, one thing that is difficult to automate in Internet Explorer is downloading files, especially if you don't want messages to appear on the user's screen.
You need to use the Windows API to programmatically interact with the Save As dialog box in Internet Explorer while keeping it hidden. The following article describes how to do this: http://www.codeproject.com/Articles/2847/Automated-IE-SaveAs-MHTML This article uses C ++, but you can make the same API calls from VBA.
I think it is a matter of developing what SAML server it uses, and the solution, which will be easier: (a) automate Internet Explorer, or (b) create your own SAML client.
If you are going to write your own SAML client, you can use MSXML to consume and generate the required XML and base64 encoding / decoding.
source to share