5

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?

Community
  • 1
  • 1
IT Hit WebDAV
  • 5,652
  • 12
  • 61
  • 98

2 Answers2

2

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.

Community
  • 1
  • 1
  • WWW-Authenticate header and Set-Cookies header can give authentication info. However there is no access to these headers in JS without modifying server-side. – IT Hit WebDAV Jun 27 '16 at 19:01
2

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

Community
  • 1
  • 1
Nikhil Ghuse
  • 1,258
  • 14
  • 31
  • I have examined _spPageContextInfo variable. I do not see anything that can tell me about authentication. Which particular property contains authentication type? – IT Hit WebDAV Jul 01 '16 at 16:43