Making WebRequest to SharePoint using Windows Authentication in Mixed Mode Authentication

Mixed mode authentication is when both Form Based Authentication (FBA) and Windows Authentication are enabled on the SharePoint site. I was writing some code to download a file from SharePoint in this scenario. The code needs to authenticate using Windows Authentication.

I found my solution at this post: Essentially we need to add the header “X-FORMS_BASED_AUTH_ACCEPTED” to the request and set its value to “f”. I tested this on the WebClient class and it works!

As a side note, I found this post to make the request using FBA, i.e. with user name and password: Haven’t tested so don’t know if it works – but it looks promising.

Update: And if your site is using SSL, you may run into the error below in DEV/TEST:

The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel.

In which case, try setting the ServerCertificateValidationCallback as described in this post: (it worked for me!).


About Bernado

Based in Australia, I am a freelance SharePoint and Dynamics CRM developer. I love developing innovative solutions that address business and everyday problems. Feel free to contact me if you think I can help you with your SharePoint or CRM implementation.
This entry was posted in Claim Authentication, Form Based Authentication, Mixed Mode Authentication. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s