123ArticleOnline Logo
Welcome to 123ArticleOnline.com!
ALL >> Computer-Programming >> View Article

Active Authentication Of Office 365 And Sharepoint Online

Profile Picture
By Author: Dylan Rodriguez
Total Articles: 131
Comment this article
Facebook ShareTwitter ShareGoogle+ ShareTwitter Share

There is huge rise in demand for various SharePoint development services which include services like SharePoint customization, SharePoint consulting, development of customized web parts, customized migration, troubleshooting implementation issues and much more. Along with SharePoint development the developers can also help their customers to define and analyse their application requirements, guide them through different techniques for integrating business requirements and execute it over a set which is well planned.
This article gives you the details of performing active authentication to SharePoint online in Office 365. For accessing sharepoint objects programmatically you need to active authentication by using client object model, web services or WebDAV from outside of Office 365. This is not required if you are using SharePoint Online or using the web browser because in this case you are either already authenticated and it is the web browser that handles all the authentication with the use of active authentication.
SharePoint Online active AuthN basics
Let us see and understand how the code ...
... works before going deep into the actual code. The first step would be to request a token from STS which is located at login.microsoftonline in Office 365. With the use of SAML 1.1 protocol, the password and username would be passed on for the requested token from STS. STS returns the security token if authentication is successful and token is then sent to SharePoint. After the validation the token will return two cookies which must also be passed with all requests to SharePoint.
It is also very important to be aware of which Office 365 subscription that you are targeting. HTTP is used by P-subscriptions while communicating and HTTPS must be used by E-subscriptions.
How to use Client Object Model with Office 365 from a remote client
To invoke methods on SharePoint online with the use of Client Object Model (CSOM), web services or WebDAV we need to authenticate first. Next step would be to pass along the cookies for each request. After having the cookies the next step would be to create a Cookie Container object in which cookies can be added. Then the cookie container should be added to the request done by Client object model and for this an even called Executing web Request can be used. This is a responsible method for creating cookie container more on this one later. It should also be noted that a User Agent of the request to a new value. If the user agent is not set then a 403 forbidden error is thrown by SharePoint Online in the case of an E-subscription. While it works fine on P-subscriptions but doesn’t harm if added. When using manually the WebRequest objects then the same procedure is used. Adding cookies and user agent would be just fine.
Show me the code to get the cookies!
Let us get to the core of this article. How would the code look? There are some helper class originated from Steve "SharePoint Claims" Peschka.
You may use the helper class called MsOnlineClaimsHelper. It contains everything you might need for authentication, retrieving and caching the cookies and piggyback the cookie container on the CSOM web requests. Here is a simple example for it:
MsOnlineClaimsHelperclaimsHelper = new MsOnlineClaimsHelper(url, username, password);
using (ClientContext context = new ClientContext(url)) {
context.ExecutingWebRequest += claimsHelper.clientContext_ExecutingWebRequest;
context.Load(context.Web);
context.ExecuteQuery();
Console.WriteLine("Name of the web is: " + context.Web.Title);
}

For More Information:- Sharepoint Consulting | Sharepoint Customization

Total Views: 437Word Count: 550See All articles From Author

Add Comment

Computer Programming Articles

1. The Dynamic Landscape Of Advertising Agencies In Indonesia: A Hub For Creativity And Innovation
Author: milestone

2. 10 Advantages Of Building A Career In Full Stack Java Development In Bhopal
Author: Rohan Rajput

3. Top Mobile App Development Company In Canada: Comprehensive Solutions For Your Business
Author: iTechnolabs

4. Democratizing Development: The Rise Of Low-code And No-code Platforms
Author: Techeunoia International

5. Amazon Product Listing Services: Boost Your Sales With Optimized Listings
Author: rachelvandereg

6. Best Accounting Software 2025 In Zambia: Tips And Best Practices
Author: Doris oseR

7. Aryabhata And The Birth Of Zero: A Legacy That Powers Modern Ai And Machine Learning
Author: Pydun Technology Private Limited

8. Top 5 Video Conferencing Solutions Of 2025
Author: Ben Gross

9. Best Practices For Building High-performance React Native Apps
Author: William

10. Top 10 Reasons To Pursue Full Stack Java Development In India
Author: Rohan Rajput

11. Transform Your Digital Presence With Expert Drupal Development
Author: manish

12. We Provide It Solutions That Help You Succeed
Author: We provide IT solutions that help you succeed

13. What Makes A Full Stack Developer Stand Out In 2025?
Author: Shrushti Gurav

14. Effortlessly Convert Sale Orders To Purchase Orders In Odoo
Author: CodersFort

15. Best Software Development Comapny In Wayanad, Kerala, India
Author: TRUSTWAVES

Login To Account
Login Email:
Password:
Forgot Password?
New User?
Sign Up Newsletter
Email Address: