Quantcast
Channel: SharePoint 2010 - Development and Programming forum
Viewing all articles
Browse latest Browse all 11571

2010 Client Object model: Forms Authentication- 401 Unauthorized

$
0
0


I am using Client Object model for the forms authentication web application and I get 401 unauthorized error.
Tried with CredentialCache.DefaultCredentials but still no use. Please help me on this.

Thanks in Advance!


Below is my code

static void clientContext_ExecutingWebRequest(object sender, WebRequestEventArgs e)
        {
            e.WebRequestExecutor.WebRequest.Headers.Add("X-FORMS_BASED_AUTH_ACCEPTED", "f");
        }

        public static void AddDocSet(string siteUrl, string listName )
        {

            ClientContext clientContext = new ClientContext(siteUrl);
        clientContext.ExecutingWebRequest += new EventHandler<WebRequestEventArgs>(clientContext_ExecutingWebRequest);
          clientContext.AuthenticationMode = ClientAuthenticationMode.Default;


         clientContext.Credentials = new NetworkCredential("XXXX", "XXX", "YYY");
            Web web = clientContext.Web;
            List list = clientContext.Web.Lists.GetByTitle(listName);

            clientContext.Load(clientContext.Site);

            clientContext.ExecuteQuery();

}

   

Viewing all articles
Browse latest Browse all 11571

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>