Restrict access by ip

Discussion in 'ASP General' started by Ted Boyd, Oct 4, 2006.

  1. Ted Boyd

    Ted Boyd Guest

    I have an ASP page that I want to allow access from only from a certain
    block of address, can someone get me started?
    Ted Boyd, Oct 4, 2006
    #1
    1. Advertising

  2. Ted Boyd

    McKirahan Guest

    "Ted Boyd" <> wrote in message
    news:...
    > I have an ASP page that I want to allow access from only from a certain
    > block of address, can someone get me started?



    Is it a list or a range of valid IP Addresses?

    If a list then try this:

    <%
    Dim arrIPA(2)
    arrIPA(0) = "1.2.3.4"
    arrIPA(1) = "11.22.33.44"
    arrIPA(2) = "111.222.333.444"
    Dim strIPA
    strIPA = Join(arrIPA,"^")
    Dim strRSV
    strRSV = Request.ServerVariables("REMOTE_ADDR")
    If InStr(strIPA,strRSV) > 0 Then
    '.............. IPAddress is valid ................
    End If
    %>
    McKirahan, Oct 4, 2006
    #2
    1. Advertising

  3. Ted Boyd

    Evertjan. Guest

    McKirahan wrote on 04 okt 2006 in
    microsoft.public.inetserver.asp.general:
    > "Ted Boyd" <> wrote in message
    >> I have an ASP page that I want to allow access from only from a
    >> certain block of address, can someone get me started?

    >
    >
    > Is it a list or a range of valid IP Addresses?
    >
    > If a list then try this:
    >
    > <%
    > Dim arrIPA(2)
    > arrIPA(0) = "1.2.3.4"
    > arrIPA(1) = "11.22.33.44"
    > arrIPA(2) = "111.222.333.444"
    > Dim strIPA
    > strIPA = Join(arrIPA,"^")
    > Dim strRSV
    > strRSV = Request.ServerVariables("REMOTE_ADDR")
    > If InStr(strIPA,strRSV) > 0 Then
    > '.............. IPAddress is valid ................
    > End If
    > %>


    Not very safe, as it would allow:

    181.2.3.4
    211.2.33.44
    etc.

    Try:

    Dim arrIPA(3)
    arrIPA(0) = "1.2.3.4"
    arrIPA(1) = "11.22.33.44"
    arrIPA(2) = "111.222.333.444"
    Dim strIPA
    strIPA = "^" & Join(arrIPA,"^") & "^"
    Dim strRSV
    strRSV = "^" & Request.ServerVariables("REMOTE_ADDR") & "^"
    If InStr(strIPA,strRSV) = 0 Then session.abandon : response.end

    ===

    Even then I would think "REMOTE_ADDR" can be manipulated
    in the client request stream.


    --
    Evertjan.
    The Netherlands.
    (Please change the x'es to dots in my emailaddress)
    Evertjan., Oct 4, 2006
    #3
  4. Ted Boyd

    Ted Boyd Guest

    Thanks to all...


    Ted
    Ted Boyd, Oct 4, 2006
    #4
  5. Ted Boyd

    don Guest

    who do you do it if it's a block of ip??
    ---
    Posted via DotNetSlackers.com
    don, Oct 28, 2006
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Gaurav
    Replies:
    2
    Views:
    376
  2. Luis Esteban Valencia

    Restrict aspx page access only through application

    Luis Esteban Valencia, Jan 15, 2005, in forum: ASP .Net
    Replies:
    3
    Views:
    523
    Matt Berther
    Jan 15, 2005
  3. ad
    Replies:
    5
    Views:
    670
    Mark Rae
    Jun 5, 2005
  4. =?Utf-8?B?Q3VydF9DIFtNVlBd?=

    RE: Ways to restrict access to some methods in .net Components?

    =?Utf-8?B?Q3VydF9DIFtNVlBd?=, Sep 13, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    363
    =?Utf-8?B?ZG90bmV0dGVzdGVy?=
    Sep 13, 2005
  5. Anan
    Replies:
    8
    Views:
    15,609
    John C. Bollinger
    Dec 8, 2004
Loading...

Share This Page