I have the following setup: ADFS 3.0, SharePoint 2013 and the custom ASP.NET MVC app.

Both SharePoint and MVC app are configured to use Single Sign-On from ADFS, so once user is logged in via ADFS, he is automatically authenticated in both SP and MVC.

What I need to do is to use CSOM from the backend of the MVC app using ADFS authentication. I can instantiate ClientContext if I provide it with user name and password, but the goal is to somehow create it without an explicit password, based on implicit authentication provided by SSO.

My first idea was to just copy FedAuth cookies from MVC app's Request, but it didn't work. In fact I found that FedAuth cookie issued to the MVC app is different from the one issued to SP (though both use the same authentication form, voodoo!).

Then I found some older guides for SP 2010, based on manually getting token from ADFS, and then using that token to call SharePoint and grab the FedAuth cookie (for example, Connecting to SharePoint with Claims Authentication and Using the Client Object Model with a Claims Based Auth Site in SharePoint 2010). However, I wasn't able to make it work ("The HTTP request was forbidden with client authentication scheme 'Negotiate'"), and really I have no idea how that first request to ADFS would be authenticated (magic?).

What is the correct way to achieve such a task, is the second approach viable at all?

  • Have you got any update on that? – Fabio May 8 '15 at 11:30
  • Could you explain in detail on why are you not able to get it using CSOM – Harshini Hegde Jul 20 '16 at 19:02
  • just a thought, if you are using the clientContext in the backend (aspx.cs) then it means it is executing on the server. But it the client browser that will store the cookies right. Why not shift your code to the browser like button click's JavaScript....assuming this satisfies your business scenario. – Anand Oct 11 '16 at 14:21
  • HI Ovolko, you have any update on your issue? – adilahmed Nov 21 '16 at 8:39
  • Sorry guys, we switched to OAuth2 authentication both in MVC and CSOM so this route was no longer needed – ovolko Nov 21 '16 at 13:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.