How to detect SharePoint 2013/2016 authentication mode in JavaScript

818 Views Asked by At

I need to detect authentication type being used by SharePoint 2013 and 2016. I need to distinguish between ASP.NET Forms (cookies) authentication and Windows (Basi/Digest/NTLM/Ketberos) authentication.

I see that it is possible to detect authentication mode on server side: Programmatically determine authentication mode. But our SharePoint add-in is a pure JavaScript and does not have any server-side code.

Is it possible to detect SharePoint authentication in JavaScript?

2

There are 2 best solutions below

1
Datadecision team member On

I think that you should investigate the HTTP headers of your web page.

They can be read through javascript (see this link) and contain information regarding the authentication type in use.

1
Nikhil Ghuse On

I'm assuming you're on a standard SharePoint page -- if so, you can use the _spPageContextInfo object's userId and userLoginName properties.

They come along for the ride when the page is rendered.

From my browser dev tools:

Check here