I want to implement a custom logging by passing authentication information.
http://msdn.microsoft.com/en-us/library/hh147177(v=office.14).aspx
I'm using the below code but it does not automatically login instead it just popup the login window to enter username and password. I want to automatically log in by passing the credentials pro grammatically.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.SharePoint.Client;
using System.Net;
using MSDN.Samples.ClaimsAuth;
namespace Sp_Ctx
{
class Program
{
[STAThread]
static void Main(string[] args)
{
string targetSite = "https://mysite.sharepoint.com";//args[0];
using (ClientContext ctx = ClaimClientContext.GetAuthenticatedContext(targetSite))
{
if (ctx != null)
{
ctx.Credentials = new NetworkCredential("guest@mysite.com.au", "password", "mysite.sharepoint.com");
ctx.Load(ctx.Web); // Query for Web
ctx.ExecuteQuery(); // Execute
Console.WriteLine(ctx.Web.Title);
}
}
Console.ReadLine();
}
}
}
We have hosted MS 365 2013 sharepoint site but we need to use sharepoint 2010 object authentication model with sharepoint 2013 site since our hosting provider posses windows server 2008 only.
From above code authentication does not worked. I tried witha break point at
using (ClientContext ctx = ClaimClientContext.GetAuthenticatedContext(targetSite))
It gives the below exception.
"The remote server returned an error: (403) Forbidden."