Skip to main content
2 of 4
added 240 characters in body
Steve B
  • 7.6k
  • 9
  • 54
  • 110

try to use the CredentialCache (from memory) :

using (ClientContext context = new ClientContext("http://localhost"))
{
    CredentialCache cc = new CredentialCache();
    NetWorkCredential nc = new NetworkCredential("username", "password", "domain"); 

    cc.Add(new Uri("http://localhost"), nc, "Negociate"));

    context.Credentials = cc; 

    Web web = context.Web;
     context.Load(web);

    Log.Debug("Loading web.");
    context.ExecuteQuery();

    Console.WriteLine(web.Title);
}

there are also others cases where the return http code is 401, and subcode 401.1 or 401.2. Unfortunately the only way to discover them is to look inside IIS logs. the two have some causes that can be threated with different solutions. Tell us if it's the case.

[Edit] As you said you have a 401.2 error, take a look at my former answer here : 401 IIS Error for SearchAdmin.asmx. I bet it's the same.

Steve B
  • 7.6k
  • 9
  • 54
  • 110