Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Anonymous usser URL access testing issues

Anonymous usser URL access testing issues

Scheduled Pinned Locked Moved ASP.NET
questioncomsysadminwindows-admintesting
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    jboyd111
    wrote on last edited by
    #1

    I've written a simple web app to test the URLs of our various internal applications to ensure none would allow anonymous login access. I thought all was working fine until another developer mentioned that one of the URLs should be accessible to anonymous users. We use Active directory logins/passwords and membership in order to provide/restrict access to certain pages and applications. When set to default credentials, I get no errors. When I set my network credentials to some made-up user, I get 401 errors, as expected for all URLs. For the URL in question that's accessible to internal anonymous (i.e. not logged-into-this-particular-app) users, I get the "401 access denied" message as well. Here are the main parts of the code: NetworkCredential networkCredential = new NetworkCredential("stan", "abc123"); HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://www.SomeTestURLHere.com/default.aspx"); CookieContainer cookieContainer = new CookieContainer(); request.CookieContainer = cookieContainer; request.Credentials = networkCredential; using (HttpWebResponse response = (HttpWebResponse)request.GetResponse()) using (Stream dataStream = response.GetResponseStream()) using (StreamReader reader = new StreamReader(dataStream)) { // do work } This is all contained within a try-catch-finally block. With default credentials, I fall through into the "do work" section of the code. With the network credentials I set above, I get the "401" exception, which I would NOT expect for this particular URL since it's supposed to allow anonymous user access. So my question is: why am I getting the 401 message for this page? Thanks in advance for any assistance you can provide.

    ---- Jboyd

    T 1 Reply Last reply
    0
    • J jboyd111

      I've written a simple web app to test the URLs of our various internal applications to ensure none would allow anonymous login access. I thought all was working fine until another developer mentioned that one of the URLs should be accessible to anonymous users. We use Active directory logins/passwords and membership in order to provide/restrict access to certain pages and applications. When set to default credentials, I get no errors. When I set my network credentials to some made-up user, I get 401 errors, as expected for all URLs. For the URL in question that's accessible to internal anonymous (i.e. not logged-into-this-particular-app) users, I get the "401 access denied" message as well. Here are the main parts of the code: NetworkCredential networkCredential = new NetworkCredential("stan", "abc123"); HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://www.SomeTestURLHere.com/default.aspx"); CookieContainer cookieContainer = new CookieContainer(); request.CookieContainer = cookieContainer; request.Credentials = networkCredential; using (HttpWebResponse response = (HttpWebResponse)request.GetResponse()) using (Stream dataStream = response.GetResponseStream()) using (StreamReader reader = new StreamReader(dataStream)) { // do work } This is all contained within a try-catch-finally block. With default credentials, I fall through into the "do work" section of the code. With the network credentials I set above, I get the "401" exception, which I would NOT expect for this particular URL since it's supposed to allow anonymous user access. So my question is: why am I getting the 401 message for this page? Thanks in advance for any assistance you can provide.

      ---- Jboyd

      T Offline
      T Offline
      T M Gray
      wrote on last edited by
      #2

      Have you checked if IIS is configured not to allow anonymous access?

      J 1 Reply Last reply
      0
      • T T M Gray

        Have you checked if IIS is configured not to allow anonymous access?

        J Offline
        J Offline
        jboyd111
        wrote on last edited by
        #3

        It does allow it if you come in from a web browser like internet explorer. This is within a company network so no one from outside can access the site, of course. The issue is you can log out of or into this particular internal site. When you log out of it you can still access this one page. When I try this using ASP.NET (HttpWebRequest) I get the error. Perhaps someone can answer this question: By setting my own "NetworkCredential" am I being looked at like I'm trying to access the internal page as though I'm an external user?

        J 1 Reply Last reply
        0
        • J jboyd111

          It does allow it if you come in from a web browser like internet explorer. This is within a company network so no one from outside can access the site, of course. The issue is you can log out of or into this particular internal site. When you log out of it you can still access this one page. When I try this using ASP.NET (HttpWebRequest) I get the error. Perhaps someone can answer this question: By setting my own "NetworkCredential" am I being looked at like I'm trying to access the internal page as though I'm an external user?

          J Offline
          J Offline
          jboyd111
          wrote on last edited by
          #4

          Here's a brief update after poking around a bit. I notice I get different behavior when I set "NetworkCredential" to my valid username and password then when I use "CredentialCache.DefaultCredentials". When I use "NetworkCredential", I can now access the URLs that allow "anonymous" access. But I now geet "401" errors with all other URLs. In short: a. Using "CredentialCache.DefaultCredentials" gives me access to all URLs b. Using "NetworkCredential" (with correct username and password) gives me access to URLs allowing "anonymous" access. Question: why do these behave differntly?

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups