I'm trying reference a sharepoint list item in my aspx page using the Sharepoint Client Object Model. I have been granted 'Full Control' privileges on this list. The problem is that I can only complete the request when I set the ClientContext.Credentials explicitly with my password hard-coded into the page. Obviously I don't want visitors to my site to have the access to things based on my credentials.

This gets it to work but does not meet the project requirements:

ClientContext cc = new ClientContext("http://sharepoint.site.com/sitename");
cc.Credentials = new NetworkCredential("username", "password", "domain");

I have set in the web.config and seems to be working fine. When I check WindowsIdentity.GetCurrent().Name it shows my correct "domain\username" information, which I think should mean my credentials are valid. Why then, is SharePoint rejecting the cc.ExecuteQuery(); with a "System.Net.WebException The remote server returned an error: (401) Unauthorized."?

I can put a textbox on the screen that lets the user enter their password to used to create a NetworkCredential object, but I can tell you right now the customer (my Boss) is not going to be happy with this and is going tell me he wants me to find a work around.

Edit: The sharepoint site is hosted on a different site, but within the same company intranet.

2 Answers 2


Are you using kerberos, ntlm, forms or claims? My guess is you are using NTLM and running into the NTLM double hop "issue".


The easiest next step is probably to change your site over to Kerberos. I have a blog article where I outlined some resources that help when setting up kerberos in SharePoint.


  • Yeah, Its NTLM. I'm looking into your suggestions. I'll comment here if anything comes from it. Otherwise assume that the Kerberos approach was denied due to the policies of the IT department and not because your answer was flawed in any way.
    – Rex NFX
    Feb 26, 2013 at 22:28

Have you tried using DefaultCredentials instead, to pick up the identity of the current user?

Additionally: is this aspx running within your SharePoint site? If so, why are you using the Client Object Model? Just use the server OM. Far easier and much less hassle.

  • I did try CredentialCache.DefaultCredentials. It didn't help. The sharepoint site is on a different server, but within the same company intranet. When I create an aspx page on the sharepoint site with the designer, it won't let me edit any of the asp.net code.
    – Rex NFX
    Feb 26, 2013 at 15:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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