Reputation: 339
I would like to build an excel vba plug-in able to download an excel file from a intranet website which currently is protected with SAML authentication.
If I try to download the file with Internet Explorer or Google Chrome, the file automatically starts to download without putting any credential and I think this is because there is some sort of integrated windows authentication those browsers rely on.
If I try to download with a VBA object such as winhttp.winhttprequest.5.1 I get some html page that I think it is starting the SAML authentication (So I assume the winhttp.winhttprequest.5.1 object I have used does not support the SAML authentication).
Is there any easy way to do a SAML authentication with VBA or do I have to manually code the authentication steps?
Upvotes: 3
Views: 2414
Reputation: 213
The problem is that while various libraries distributed with Windows/Office will look after HTTP and SSL for you, it isn't straightforward to find one that does SAML. .NET has Windows Communication Foundation (WCF), which can be used in VBA, but I don't know how it works with websites.
If you can't get WCF to do the SAML for you, the easiest way might be to automate Internet Explorer, since Internet Explorer already contains the SAML functionality. Unfortunately, the one thing that is hard to automate in Internet Explorer is downloading files, particularly if you don't want things popping up on the user's screen.
You need to use the Windows API to programmatically interact with Internet Explorer's "Save As" dialog box 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 guess its a matter of working out what kind of SAML the server is using, and deciding what would be easier: (a) automating Internet Explorer or (b) writing your own SAML client.
If you are going to write your own SAML client, you can use MSXML to consume and produce the required XML and encode/decode base64.
Upvotes: 2