473,406 Members | 2,259 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

403 Forbidden Error Due To Incorrect Impersonation Level

I'm using HttpWebRequest and HttpWebResponse to query a remote server. I plan to load the returned xml into an XMLDocument, but the HttpWebRequest.GetResponse() method fails with a 403 "Forbidden" error.

I am able to get a response when I put my domain username and password as plain text into the request's Credentials member, but of course I'd like to avoid having that information in the application.

I thought that code along these lines (found at http://claytonj.wordpress.com/2006/0...-user-context/)
would solve my problem:
Expand|Select|Wrap|Line Numbers
  1. using System.Security.Principal;
  2.  
  3. if (User.GetType() == typeof(WindowsPrincipal))
  4. {
  5.     WindowsIdentity id = (WindowsIdentity) User.Identity;
  6.     WindowsImpersonationContext impersonate = id.Impersonate();
  7.  
  8.     //perform tasks under the impersonated user
  9.     //*** ***//
  10.  
  11.     //revert back to local ASPNET account
  12.     impersonate.Undo();
  13. }
  14. else
  15. {
  16.     //user isn’t authenticated
  17. }
  18.  
But, I still get the 403 error. I think the impersonation is failing because the WindowsIdentity.ImpersonationLevel property is always "Impersonation." I think this needs to be "Delegation" to reach the remote server (I'm behind a firewall and corporate proxy), but the property is read-only so I can't set it.
My Question: What do I need to configure in order to get the ImpersonationLevel property to be of the TokenImpersonationLevel.Delegation type?

Let me know if this requires clarification.
Apr 30 '08 #1
1 2149
Plater
7,872 Expert 4TB
Well I don't think changing the impresonation level of your program effects what data is sent down accross an HttpWebRequest object.
There is a bunch of properties on that object that deal with sending credentials, I think maybe you could set one of those to user credentials?

You could also packet watch what a regular browser does to send the information?
May 1 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Dave | last post by:
I am running Windows XP Pro, with SP2. I recently downloaded PHP 4.3.10, which installed successfully, to F:\PHP. As suggested, I ensured that the IUSR_MachineName account had appropriate access...
3
by: Wm. Scott Miller | last post by:
What is the difference between using a username and password in the processmodel section vs using one in impersonation in the machine.config file? What are the advantages of each and what are the...
8
by: Razak | last post by:
Hi, I have a class which basically do Impersonation in my web application. From MS KB sample:- ++++++++++++++++++++code starts Dim impersonationContext As...
5
by: Paul Bergson | last post by:
I have been trying to get a process to start up and run with arguments passed to it. I have gotten close (Thanks to help from this board) but I there is a failure while I'm running this because...
11
by: Phil | last post by:
Hi, I've currently setup a local user as described in: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnne...
5
by: Jay | last post by:
have some methods(signIn()) in MyService.dll, that I use from my webpage. SignIn() { requestCommand = (HttpWebRequest)WebRequest.Create(http://myserver/cwa/MainCommandHandler.ashx); ...
23
by: deathtospam | last post by:
A day or two ago, I wrote a quick ASPX page with a CS codebehind using Visual Studio .NET 2005 -- it worked, I saved it and closed the project. Today, I came back to the project, reopened the...
0
by: Mitko Haralanov | last post by:
Hi Dave, I have some questions about the ipath error messages that we print out. I am currently testing the error injection part of the matrix and I starting with "incorrect checksum" and...
1
by: =?Utf-8?B?Tko=?= | last post by:
Hi everyone, Every now and then I'm receiving the error posted below. I"m routing all my traffic through mod_proxy (apache) to my asp.net 2.0 (w2k3) machine. I can't reproduce this error and my...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.