This article walks through the process of using the SharePoint Data Provider and authenticating with SharePoint
Online / Office 365. This tutorial covers how to perform this programmatically and with the Visual Studio Server Explorer.
In addition to accessing lists from local installations of SharePoint server,
the SharePoint Data Provider also supports accessing lists from SharePoint Online. SharePoint Online and
Office 365 authentication requires a cookie based authentication. To connect to SharePoint
Online please follow the steps below.
Authenticating to SharePoint Online in your program.
- Step 1:
Point Internet Explorer to 'http://YOUR_DOMAIN.sharepoint.com/TeamSite' which will redirect you to an authentication page. Be Sure to check the 'Keep-Me-Signed-In'
option at login.
- Step 2:
Now that you have authenticated to SharePoint Online through your web browser, the cookie that was retrieved must be passed to the Auth Cookie connection setting.
If you used Internet Explorer to log into SharePoint Online then you set Auth Cookie to '*' and the Data Provider will pick up the cookie automatically from IE.
Here is an example of how to set this in your application:
DataTable table = new DataTable();
String command = "SELECT * FROM Calendar";
SharePoinConnection conn = new SharePointConnection( "URL=http://YOUR_DOMAIN.sharepoint.com/TeamSite; Auth Cookie='*'");
SharePointDataAdapter adapter = new SharePointDataAdapter(command, conn);
Authenticating with Server Explorer.
To set the 'Auth Cookie' with the Server Explorer in Visual Studio you will have to have completed Step 1 from above first. Then after the
cookie has been retrieved you can add new connection:
Now you need to add the URL and wildcard charater, '*', and the explorer will construct the connection string for you:
After following the steps above, you can use the provider just like you would when connected to a local SharePoint server. This procedure can also be applied to
Entity Framework and Microsoft LightSwitch projects.
If you have any further questions about this you can email our