I want to connect to SP2010 server with claims based authorization via client context. But I have security issue. First I didn't managed to connect with default credentials. Then I wrote:
NetworkCredential credentials = new NetworkCredential("myusername", "mypass"); clientContext.Credentials = credentials;
After that i got error status: "Forbidden". I googled and found this solution:
static void clientContext_ExecutingWebRequest(object sender, WebRequestEventArgs e){ e.WebRequestExecutor.WebRequest.Headers.Add("X-FORMS_BASED_AUTH_ACCEPTED", "f");
clientContext.ExecutingWebRequest += new EventHandler(clientContext_ExecutingWebRequest);
I did that also, but then got error: "Unauthorized", despite the fact that i have user with above credentials and I can normally logon with his username and password.
Any suggestion?
Update: If I remove "NetworkCredential credentials = new NetworkCredential("myusername", "mypass"); clientContext.Credentials = credentials;" and leave above eventhandler, I become able to execute client context. I assume that he now use windows authentication and that is ok, in some way. But what I must do to enable forms-based (membership provider) auth via client context? Is that even possible?