Intranet Screen Scrape (Passing Authentication)

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

  1. #1

    Default Intranet Screen Scrape (Passing Authentication)

    I would like to read a page programmatically with an ASP.NET intranet site.
    I am using forms authentication. No matter what I have tried, the login
    screen always comes back because the web server itself knows nothing about
    the authentication information already stored away. I admit that I am a
    little bit clueless about this whole process, so any info would help. I
    have read where people say that you need to pass a cookie, using a cookie
    container, but I'm not sure how exactly that is done and what cookie to
    pass. I'm using tickets when a comes in under the login screen.

    Will post the code later, but for now, just wondering if someone has a clear
    consice example (or at least an explanation) of what I have to do to get
    past the forms authentication?


    Johnny Quest Guest

  2. Similar Questions and Discussions

    1. Catch user control time out (screen scrape)
      Morning, I've created a user control that uses a bit stream reader to screen scrape a page from a partnering URL. The problem is, sometimes this...
    2. using Windows authentication within intranet
      I would like to set up a web service to use Windows authentication. I understand how to do this in a situation where the client passes a...
    3. Intranet windows authentication
      Hello. I'm currently developing an intranet c# based application. I need to assign a windows login authentication form for users who needs to...
    4. IntraNet Authentication
      Hello all, I hope my question is not too basic. I am working on an intranet and would like to avoid prompting users for a login. I know that...
    5. Is it possible to screen scrape a secure site (HTTPS).....
      I know you can screen scrape a website using the System.Net.HttpWebResponse & System.Net.HttpWebRequest classes. But how do you screen scrape a...
  3. #2

    Default Re: Intranet Screen Scrape (Passing Authentication)

    Johnny Quest wrote:
    >I would like to read a page programmatically with an ASP.NET intranet site.
    >I am using forms authentication. No matter what I have tried, the login
    >screen always comes back because the web server itself knows nothing about
    >the authentication information already stored away. I admit that I am a
    >little bit clueless about this whole process, so any info would help. I
    >have read where people say that you need to pass a cookie, using a cookie
    >container, but I'm not sure how exactly that is done and what cookie to
    >pass. I'm using tickets when a comes in under the login screen.
    >
    >Will post the code later, but for now, just wondering if someone has a clear
    >consice example (or at least an explanation) of what I have to do to get
    >past the forms authentication?
    >
    >
    >
    >
    Johnny,

    Have a look at System.Net.HttpRequest.

    Is the page being screen scraped an ASP.NET page using forms authentication?

    Kevin

    Kevin Kenny Guest

  4. #3

    Default Re: Intranet Screen Scrape (Passing Authentication)

    Yes, forms authentication. The part I don't understand (and obviously
    critical) is what is needed to satisfy the following piece of code in
    global.asax? I always, always, always get the login page. When I try and
    use CookieContainer, there is some quirks with using the Cookie object from
    System.Net versus System.Web and I don't fully understand that either.

    Hope someone can shed some light on this?

    protected void Application_AuthenticateRequest(Object sender, EventArgs e)

    {

    if (HttpContext.Current.User != null)

    {

    if (HttpContext.Current.User.Identity.IsAuthenticated )

    {

    if (HttpContext.Current.User.Identity is FormsIdentity)

    {

    FormsIdentity id = (FormsIdentity)HttpContext.Current.User.Identity;

    FormsAuthenticationTicket ticket = id.Ticket;

    // Get the stored user-data, in this case, our roles

    string userData = ticket.UserData;

    string[] roles = userData.Split(',');

    HttpContext.Current.User = new GenericPrincipal(id, roles);

    }

    }

    }

    }

    After authentication, login page goes like this:



    // Create a new ticket used for authentication

    FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(

    1, // Ticket version

    UserName.Text, // Username associated with ticket

    DateTime.Now, // Date/time issued

    DateTime.Now.AddMinutes(1000), // Date/time to expire

    true, // "true" for a persistent user cookie

    cmrRoles, // User-data, in this case the roles

    FormsAuthentication.FormsCookiePath); // Path cookie valid for


    // Hash the cookie for transport

    string hash = FormsAuthentication.Encrypt(ticket);

    HttpCookie cookie = new HttpCookie(

    FormsAuthentication.FormsCookieName, // Name of auth cookie

    hash); // Hashed ticket


    // Add the cookie to the list for outgoing response

    // this I am hoping will stop the frequent timeouts from occurring.

    cookie.Expires=ticket.Expiration;

    Response.Cookies.Add(cookie);

    ----- Original Message -----
    From: "Kevin Kenny" <kevin.kenny@snip.me.zygonia.net>
    Newsgroups: microsoft.public.dotnet.framework.aspnet.security
    Sent: Sunday, August 31, 2003 5:57 AM
    Subject: Re: Intranet Screen Scrape (Passing Authentication)

    > Johnny Quest wrote:
    >
    > >I would like to read a page programmatically with an ASP.NET intranet
    site.
    > >I am using forms authentication. No matter what I have tried, the login
    > >screen always comes back because the web server itself knows nothing
    about
    > >the authentication information already stored away. I admit that I am a
    > >little bit clueless about this whole process, so any info would help. I
    > >have read where people say that you need to pass a cookie, using a cookie
    > >container, but I'm not sure how exactly that is done and what cookie to
    > >pass. I'm using tickets when a comes in under the login screen.
    > >
    > >Will post the code later, but for now, just wondering if someone has a
    clear
    > >consice example (or at least an explanation) of what I have to do to get
    > >past the forms authentication?
    > >
    > >
    > >
    > >
    > Johnny,
    >
    > Have a look at System.Net.HttpRequest.
    >
    > Is the page being screen scraped an ASP.NET page using forms
    authentication?
    >
    > Kevin
    >
    Yes, forms authentication. The part I don't understand (and obviously
    critical) is what is needed to satisfy the following piece of code in
    global.asax? I always, always, always get the login page. When I try and
    use CookieContainer, there is some quirks with using the Cookie object from
    System.Net versus System.Web and I don't fully understand that either.

    Hope someone can shed some light on this?

    protected void Application_AuthenticateRequest(Object sender, EventArgs e)

    {

    if (HttpContext.Current.User != null)

    {

    if (HttpContext.Current.User.Identity.IsAuthenticated )

    {

    if (HttpContext.Current.User.Identity is FormsIdentity)

    {

    FormsIdentity id = (FormsIdentity)HttpContext.Current.User.Identity;

    FormsAuthenticationTicket ticket = id.Ticket;

    // Get the stored user-data, in this case, our roles

    string userData = ticket.UserData;

    string[] roles = userData.Split(',');

    HttpContext.Current.User = new GenericPrincipal(id, roles);

    }

    }

    }

    }

    After authentication, login page goes like this:



    // Create a new ticket used for authentication

    FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(

    1, // Ticket version

    UserName.Text, // Username associated with ticket

    DateTime.Now, // Date/time issued

    DateTime.Now.AddMinutes(1000), // Date/time to expire

    true, // "true" for a persistent user cookie

    cmrRoles, // User-data, in this case the roles

    FormsAuthentication.FormsCookiePath); // Path cookie valid for


    // Hash the cookie for transport

    string hash = FormsAuthentication.Encrypt(ticket);

    HttpCookie cookie = new HttpCookie(

    FormsAuthentication.FormsCookieName, // Name of auth cookie

    hash); // Hashed ticket


    // Add the cookie to the list for outgoing response

    // this I am hoping will stop the frequent timeouts from occurring.

    cookie.Expires=ticket.Expiration;

    Response.Cookies.Add(cookie);

    ----- Original Message -----
    From: "Kevin Kenny" <kevin.kenny@snip.me.zygonia.net>
    Newsgroups: microsoft.public.dotnet.framework.aspnet.security
    Sent: Sunday, August 31, 2003 5:57 AM
    Subject: Re: Intranet Screen Scrape (Passing Authentication)

    > Johnny Quest wrote:
    >
    > >I would like to read a page programmatically with an ASP.NET intranet
    site.
    > >I am using forms authentication. No matter what I have tried, the login
    > >screen always comes back because the web server itself knows nothing
    about
    > >the authentication information already stored away. I admit that I am a
    > >little bit clueless about this whole process, so any info would help. I
    > >have read where people say that you need to pass a cookie, using a cookie
    > >container, but I'm not sure how exactly that is done and what cookie to
    > >pass. I'm using tickets when a comes in under the login screen.
    > >
    > >Will post the code later, but for now, just wondering if someone has a
    clear
    > >consice example (or at least an explanation) of what I have to do to get
    > >past the forms authentication?
    > >
    > >
    > >
    > >
    > Johnny,
    >
    > Have a look at System.Net.HttpRequest.
    >
    > Is the page being screen scraped an ASP.NET page using forms
    authentication?
    >
    > Kevin
    >

    Johnny Quest 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