SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

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

I am making a page in SharePoint that is used to proxy other content in SharePoint. The user is authenticated at the time they hit this proxy page, but I am getting an Unauthorized Access error.

The page has the following code behind:

var request = (HttpWebRequest) WebRequest.Create(urlToProxy);
request.Method = "GET";
request.Credentials = CredentialCache.DefaultNetworkCredentials; //This isn't working, apparently
var response = (HttpWebResponse) request.GetResponse();

My first thought was to use the credentials from the incoming WebRequest, but this is an HttpRequest and doesn't seem to have the Credentials property.

Does anyone know how I can pass the user's existing logged in credentials to this outgoing HttpWebRequest?

share|improve this question
Is this NTLM, Kerberos or Claims? – Dave Wise Feb 28 '13 at 22:49
It is NTLM. Thanks. – MgSam Mar 5 '13 at 19:13

It sounds like you are facing the infamous double-hop issue. In a nutshell, with NTLM you are authenticated to the server, but your credentials cannot be used by the server to access other servers.

Here is a good MSDN blog post explaining it:

Basically you either have to use a service account (one you can access the credentials for in your code, storing them in the web.config or in the Secure Store Service) or use a different authentication method that lets you pass the credentials (i.e. kerberos).

share|improve this answer
Ok, so to get around that, I'm now trying to hardcode specific credentials just for this proxy page. I'm trying do request.Credentials = new NetworkCredential(@"username", "password"){Domain = "domain"} but this isn't working. Any ideas what's wrong here? – MgSam Mar 1 '13 at 21:54
You might try creating a Credential Cache that you add your credentials to. See the end of for an example. – John Chapman Mar 1 '13 at 21:58
CredentialCache cache = new CredentialCache(); cache.Add(new Uri(""), "Negotiate", loginCredentials); cache.Add(new Uri(""), "Negotiate", loginCredentials); request.Credentials = cache; - See more at:… – John Chapman Mar 1 '13 at 22:00
This works for certain SharePoint pages, but unfortunately not the Office Web Apps, which is what I am trying to proxy. I'll post a solution if I find one. Thanks for your help. – MgSam Mar 5 '13 at 19:14

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.