SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How to add item to SharePoint list from window application using claim based authentication ? it gives 401 forbidden error. user is authenticated from ADFS server.

share|improve this question

how about following msdn? try using ClaimClientContext.GetAuthenticatedContext instead

string targetSite = "http://SharePointServer/";
using (ClientContext CNX = ClaimClientContext.GetAuthenticatedContext(targetSite))
            //Load Libraries from SharePoint

            using (FileStream fs = new FileStream(fileName.ToString(), FileMode.Open, FileAccess.Read))

                Microsoft.SharePoint.Client.File.SaveBinaryDirect(CNX, "/" + "Shared Documents" + "/" + System.IO.Path.GetFileName(fileName.ToString()), fs, true);

if it doesnt work and still returns a 403 than it has to be an issue with ADFS not setup properly! check and refer to this:


after some digging about i did find this:

they have a similar issue to you and required authentication from adfs! the issue is its complex and so he made a quick bolg on his findings:

his solution :

share|improve this answer
its asking for username and password.. not authenticate window user – Rajesh Joshi Apr 11 '13 at 11:42
ammended the answer – ali Sharepoint Apr 11 '13 at 13:26
please dont just add alot of external links! Those links tend to move/die/get lost. Instead please add some examples from the external links, and then link to answer. – Anders Rask May 14 '13 at 12:58

Please make sure that your Build Configuration for your windows application is set to

Platform Target: (Any CPU)


Platform Target (x64)

in Project Properties --> Build --> General in Visual studio

For setting permissions on ClientContext:

CNX.Credentials = new NetworkCredential("user", "password", "domain");


CNX.Credentials = CredentialCache.DefaultCredentials;

Also, have you seen this blogpost? It has some helper dll that seems to be helpful

share|improve this answer
its giving error because of adfs authentication. i cant get authenticated client context – Rajesh Joshi Apr 11 '13 at 9:32
Why do you need the client context to add an item to a list? – Robert Lindgren Apr 11 '13 at 9:36
because i m adding item from window application and context is authenticated from adfs – Rajesh Joshi Apr 11 '13 at 9:42
Can you please post some of your code so we can get an idea of your approach – Robert Lindgren Apr 11 '13 at 9:47
Please see my updated answer – Robert Lindgren Apr 11 '13 at 10:33

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.