Connect To Office 365 SharePoint Online site through SOAP service, authenticate user and get the list of all SharePoint List .
1. Authenticate User Function , Get Authenticate cookie -
public static CookieContainer GetAuthCookies(Uri webUri, string userName, string password)
{
var securePassword = new SecureString();
foreach (char c in password) { securePassword.AppendChar(c); }
var credentials = new SharePointOnlineCredentials(userName, securePassword);
var authCookie = credentials.GetAuthenticationCookie(webUri);
var cookieContainer = new CookieContainer();
cookieContainer.SetCookies(webUri, authCookie);
return cookieContainer;
}
2. Connect to SharePoint Online SOAP Service
var webUri = new Uri("https://MyTest.sharepoint.com/");
Lists list = new Lists(); //SharePoint Lists SOAP Service
list.CookieContainer = GetAuthCookies(webUri,"userName","password");
XmlNode result = list.GetListCollection();
var docResult = XDocument.Parse(result.OuterXml);
XNamespace s = "http://schemas.microsoft.com/sharepoint/soap/";
var listEntries = from e in docResult.Descendants(s + "List")
select new
{
Title = e.Attribute("Title").Value
};
Also Applicable For -
Connect with SharePoint Online Web Services to access list
Authenticate Office 365 SharePoint Online SOAP Services
Get All Lists from Office 365 SharePoint Online Site
No comments:
Post a Comment