We're trying to connect to an on premise installation of SharePoint 2013 which authenticates using ADFS. Our Development was done using Office 365 installation where the following code works perfectly fine for authentication (and fetching all items from a particular list).
public void DeleteAllItemsFromCalendar(string ListName, string SiteUrl, string UserName, string Password)
{
ClientContext content = new ClientContext(SiteUrl);
content.Credentials = new SharePointOnlineCredentials(UserName, convertToSecureString(Password));
content.ExecuteQuery();
List list = content.Web.Lists.GetByTitle(ListName);
CamlQuery query = new CamlQuery();
query.ViewXml = "<Query><OrderBy><FieldRef Name='ID' /></OrderBy></Query>";
ListItemCollection allitems = list.GetItems(query);
content.Load(allitems);
content.ExecuteQuery();
// do something with items.
}
Is this same code supposed to work for an in-premise SharePoint 2013 or is the "SharePointOnlineCredentials" class exclusively for Office 365 based SharePoint installations? We tried by passing the URL of the inpremise site and the credentials of an in premise site keeping the code intact and the code seems to give a “Catastrophic Error” Exception.
If the "SharePointOnlineCredentials" class is exclusively for Office 365, are there any pointers to simple ways to connect to an in premise SharePoint 2013 instance that authenticates using ADFS 2.0?
I've looked at multiple hand built solutions like this TechNet Blog but clearly none of them seem to work with SharePoint 2013.
Any help will be appreciated.