Guest User

Untitled

a guest
Sep 6th, 2018
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.49 KB | None | 0 0
  1. ClientContext clientContext = new ClientContext("https://innergen.sharepoint.com/sites/mydevsite");
  2. Web web = clientContext.Web;
  3. clientContext.Load(web);
  4. clientContext.ExecuteQuery();
  5.  
  6. Console.WriteLine("Web Site Name : " + web.Title);
  7. Console.ReadLine();
  8.  
  9. NetworkCredential credentials =
  10. new NetworkCredential("username", "pwd", "domain");
  11. clientContext .Credentials = credentials;
  12.  
  13. clientContext.Credentials = System.Net.CredentialCache.DefaultNetworkCredentials;
  14.  
  15. using (ClientContext clientContext = new ClientContext("HTTPS://YOURSHAREPOINTONLINESITE"))
  16. {
  17. string userName = "xyz";
  18. string password = "abc";
  19. SecureString secpassword = new SecureString();
  20. foreach (char c in password.ToCharArray()) secpassword.AppendChar(c);
  21. // SharePoint Online Credentials
  22. clientContext.ExecutingWebRequest += clientContext_ExecutingWebRequest;
  23. clientContext.Credentials = System.Net.CredentialCache.DefaultNetworkCredentials;
  24. // Get the SharePoint web
  25. Web web = clientContext.Web;
  26. // Load the Web properties
  27. clientContext.Load(web);
  28. // Execute the query to the server.
  29. clientContext.ExecuteQuery();
  30. // Web properties - Display the Title and URL for the web
  31. Console.WriteLine("Title: " + web.Title + "; URL: " + web.Url);
  32. Console.ReadLine();
  33. Console.ReadKey();
  34. }
Add Comment
Please, Sign In to add comment