Configuring CORS and NTLM Authentication for SharePoint 2016 On-Premise REST API with Different Domains (2024)

Abstract: This article provides a detailed solution to configure CORS and NTLM authentication for accessing SharePoint 2016 On-Premise REST API from a different domain.

2024-06-11 by DevCodeF1 Editors

Configuring CORS and NTLM Authentication for SharePoint 2016 On-Premise REST API (Different Domains)

Cross-Origin Resource Sharing (CORS) is a security feature implemented in modern web browsers that restricts web pages from making requests to a different domain than the one that served the web page. However, there are situations where allowing cross-domain requests is necessary, such as when building a client-side web application that needs to access resources from a different domain. This article will cover the process of configuring CORS and NTLM Authentication for SharePoint 2016 On-Premise REST API when the client and server are in different domains.

What is CORS and NTLM Authentication?

CORS is a W3C specification that enables web applications to make cross-origin HTTP requests. It allows servers to specify which origins are allowed to access their resources, providing a secure and controlled way to enable cross-domain requests. NTLM (NT LAN Manager) is a security protocol used in Windows environments for authentication and access control.

Configuring CORS for SharePoint 2016 On-Premise REST API

To configure CORS for SharePoint 2016 On-Premise REST API, you need to make changes to the web.config file of the SharePoint web application. The following steps will guide you through the process:

  1. Open the web.config file of the SharePoint web application.
  2. Locate the section.
  3. Add the following code inside the section:

<httpProtocol> <customHeaders> <add name="Access-Control-Allow-Origin" value="*" /> <add name="Access-Control-Allow-Methods" value="GET, POST, PUT, DELETE, OPTIONS" /> <add name="Access-Control-Allow-Headers" value="Content-Type, Accept, Authorization, X-RequestDigest" /> <add name="Access-Control-Allow-Credentials" value="true" /> </customHeaders></httpProtocol>

The above code allows all origins (value="\*"), all HTTP methods (value="GET, POST, PUT, DELETE, OPTIONS"), and all headers (value="Content-Type, Accept, Authorization, X-RequestDigest") to access the SharePoint REST API. The "Access-Control-Allow-Credentials" header is set to "true" to allow sending credentials (such as cookies or NTLM tokens) with cross-origin requests.

Configuring NTLM Authentication for SharePoint 2016 On-Premise REST API

To configure NTLM Authentication for SharePoint 2016 On-Premise REST API, you need to make changes to the web.config file of the SharePoint web application. The following steps will guide you through the process:

  1. Open the web.config file of the SharePoint web application.
  2. Locate the section.
  3. Add the following code inside the section:

<authentication mode="Windows" /><authorization> <allow users="*" /></authorization>

The above code sets the authentication mode to "Windows" and allows all users ("\*") to access the SharePoint web application. Note that allowing all users is not recommended for production environments. You should replace "\*" with a specific group or user that has access to the SharePoint web application.

Testing CORS and NTLM Authentication

To test CORS and NTLM Authentication, you can use a tool such as Postman or Fiddler to send cross-origin requests to the SharePoint REST API. Make sure to include the NTLM token or cookie in the request headers. If everything is configured correctly, you should receive a successful response from the SharePoint REST API.

  • CORS is a security feature that restricts web pages from making requests to a different domain than the one that served the web page.
  • NTLM is a security protocol used in Windows environments for authentication and access control.
  • To configure CORS for SharePoint 2016 On-Premise REST API, you need to make changes to the web.config file of the SharePoint web application.
  • To configure NTLM Authentication for SharePoint 2016 On-Premise REST API, you need to make changes to the web.config file of the SharePoint web application.
  • Testing CORS and NTLM Authentication can be done using tools such as Postman or Fiddler.

References

Learn how to overcome issues with CORS and NTLM authentication when accessing SharePoint 2016 On-Premise REST API from a different domain.

Configuring CORS and NTLM Authentication for SharePoint 2016 On-Premise REST API with Different Domains (2024)

References

Top Articles
Latest Posts
Article information

Author: Dan Stracke

Last Updated:

Views: 5911

Rating: 4.2 / 5 (63 voted)

Reviews: 86% of readers found this page helpful

Author information

Name: Dan Stracke

Birthday: 1992-08-25

Address: 2253 Brown Springs, East Alla, OH 38634-0309

Phone: +398735162064

Job: Investor Government Associate

Hobby: Shopping, LARPing, Scrapbooking, Surfing, Slacklining, Dance, Glassblowing

Introduction: My name is Dan Stracke, I am a homely, gleaming, glamorous, inquisitive, homely, gorgeous, light person who loves writing and wants to share my knowledge and understanding with you.