HttpWebRequest, impersonation and DefaultCredentials problem.

Ask a Question related to ASP.NET Security, Design and Development.

  1. #1

    Default HttpWebRequest, impersonation and DefaultCredentials problem.

    I'm trying to create a HttpWebRequest object that uses the current logged in
    user's credentials.

    It's currently setup with:
    <identity impersonate="true" /> in web.config
    IIS - Windows Authentication
    IIS - Anonymous access disabled

    making the request like this:
    HttpWebRequest webrequest =
    (HttpWebRequest)WebRequest.Create("http://myserver/site/page.aspx);
    webrequest.Credentials = CredentialCache.DefaultCredentials;
    HttpWebResponse webresponse = (HttpWebResponse)webrequest.GetResponse();


    I've verified that impersonate is working correctly on the aspx page by
    printing out:
    System.Security.Principal.WindowsIdentity.GetCurre nt().Name.ToString();

    It's also using windows authentication properly, i've verified that by
    printing out: Page.User.Identity.Name.ToString();

    It only seems to work when I browse to the page from the same system as the
    webserver. When i go to another system
    and browse to the web page i get a (401) unauthorized error message.

    Any ideas?


    Jamie Guest

  2. Similar Questions and Discussions

    1. DefaultCredentials problem?
      Hi All, this is the scenario: - "Hello World" web service on Machine A - winform client on Machine B - asp.net webform client on Machine B ...
    2. Problem using HttpWebRequest/HttpWebResponse with HTTPS
      Did you ever solve this problem? If so, please can you let me know how as I am trying to do something similar. richard.beacroft@warnerbros.com ...
    3. HTTPWebRequest + Cookies problem
      Hi, In continue to another post which I have in this news group, I was able to find out some more details about the problem What is my...
    4. HttpWebRequest Session Length Problem
      I need to send multiple WebRequests in the same session. The problem is I send the first request, which is a login request, receive the reply that...
    5. ASP.NET Impersonation, XmlUrlResolver, and DefaultCredentials
      I'm trying to write an ASP.NET page that does on-the-fly XML/XSL transformation. The code is as follows: --- Dim xmlPath As String =...
  3. #2

    Default Re: HttpWebRequest, impersonation and DefaultCredentials problem.

    This is a very common pitfall.

    Here are a couple links.
    [url]http://support.microsoft.com/default.aspx?scid=kb;en-us;810572[/url] (there are
    more at the bottom of this linked article too)
    [url]http://blogs.geekdojo.net/justin/archive/2003/12/10/430.aspx[/url] .

    Long story short, unless you plan to deploy AD or already running (but
    obviously not configured for delegation) you will need to come up with a
    different means of propagating the credentials.

    Kevin Cunningham

    "Jamie" <spammerssuck@nospam.com> wrote in message
    news:uIWgmLHAEHA.2308@tk2msftngp13.phx.gbl...
    > I'm trying to create a HttpWebRequest object that uses the current logged
    in
    > user's credentials.
    >
    > It's currently setup with:
    > <identity impersonate="true" /> in web.config
    > IIS - Windows Authentication
    > IIS - Anonymous access disabled
    >
    > making the request like this:
    > HttpWebRequest webrequest =
    > (HttpWebRequest)WebRequest.Create("http://myserver/site/page.aspx);
    > webrequest.Credentials = CredentialCache.DefaultCredentials;
    > HttpWebResponse webresponse = (HttpWebResponse)webrequest.GetResponse();
    >
    >
    > I've verified that impersonate is working correctly on the aspx page by
    > printing out:
    > System.Security.Principal.WindowsIdentity.GetCurre nt().Name.ToString();
    >
    > It's also using windows authentication properly, i've verified that by
    > printing out: Page.User.Identity.Name.ToString();
    >
    > It only seems to work when I browse to the page from the same system as
    the
    > webserver. When i go to another system
    > and browse to the web page i get a (401) unauthorized error message.
    >
    > Any ideas?
    >
    >

    Kevin C Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139