I am creating a console application to create Subsite's, lists, list items etc. I have a simple function that checks if a SiteCollection
exists and am met with a 403 Forbidden
error when calling the ClientContext.ExecuteQuery()
function.
Example Code:
using (ClientContext ctx = new ClientContext(url))
{
Web web = ctx.Web;
ctx.Load(web);
ctx.ExecuteQuery(); //403 Error
}
So I read this thread which detailed passing NetworkCredential
object to the context. So I changed my code to:
using (ClientContext ctx = new ClientContext(url))
{
Web web = ctx.Web;
ctx.Load(web);
ctx.Credentials = new NetworkCredential("MyUserName", "pass", "domain");
ctx.ExecuteQuery(); //Still 403's
}
It still 403's and I have gone back to verify the accounts credentials and permissions across the site that I am attempting to access.
Is there an issue with my code or is it something else? Can CSOM
go cross server?
UPDATE
The code above works on a server with Active Directory
, but not a server utilizing ADFS
. ADFS
possibly blocking this call?