Responsive Ads Here

Thursday, October 16, 2014

Connect to SharePoint Online using .net CSOM in SharePoint 2013

Let us see how to connect to SharePoint Online site using .net managed client object model in SharePoint 2013.
The process of connecting to the SharePoint Online using .net CSOM has been greatly simplified. The process has been simplified by Introducing the SharePointOnlineCredentials class. 
Please find the below Sample code how to connect to SharePoint online site.


using (ClientContext clientContext = new ClientContext("https://yoursite.sharepoint.com/"))
{
    SecureString passWord = new SecureString();
 
    foreach (char c in "yourpassword".ToCharArray()) passWord.AppendChar(c);
 
    clientContext.Credentials = new SharePointOnlineCredentials("loginname@yoursite.onmicrosoft.com", passWord);
 
    Web web = clientContext.Web;
 
    clientContext.Load(web);
 
    clientContext.ExecuteQuery();
 
    Console.WriteLine(web.Title);
 
    Console.ReadLine();
}

1 comment:

  1. Merkur Classic Classic Stainless Steel Eyewear Eyewear
    The Merkur Classic Series is a classic titanium bong chrome plated double-edge razor titanium cost with babyliss pro nano titanium flat iron chrome finish. The knurled handle titanium welding is approximately 3" long, making for titanium exhaust an easy  Rating: 4.7 · ‎14 reviews

    ReplyDelete