Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > Restrict access by ip

Reply
Thread Tools

Restrict access by ip

 
 
Ted Boyd
Guest
Posts: n/a
 
      10-04-2006
I have an ASP page that I want to allow access from only from a certain
block of address, can someone get me started?


 
Reply With Quote
 
 
 
 
McKirahan
Guest
Posts: n/a
 
      10-04-2006

"Ted Boyd" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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
%>


 
Reply With Quote
 
 
 
 
Evertjan.
Guest
Posts: n/a
 
      10-04-2006
McKirahan wrote on 04 okt 2006 in
microsoft.public.inetserver.asp.general:
> "Ted Boyd" <(E-Mail Removed)> 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)
 
Reply With Quote
 
Ted Boyd
Guest
Posts: n/a
 
      10-04-2006
Thanks to all...


Ted


 
Reply With Quote
 
don
Guest
Posts: n/a
 
      10-28-2006
who do you do it if it's a block of ip??
---
Posted via DotNetSlackers.com
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I restrict VPN Client access ? Brian P. Cisco 2 03-16-2005 11:59 AM
Restrict aspx page access only through application Luis Esteban Valencia ASP .Net 3 01-15-2005 04:14 PM
To restrict the access via MAC addresses. Franck Cisco 5 01-06-2005 05:51 PM
How to restrict direct access to JSP files, only allow access via servlet? Anan Java 8 12-08-2004 11:16 PM
Restrict access to resources like .doc, .ppt etc in .net forms authentication application Gaurav ASP .Net 2 04-05-2004 09:08 AM



Advertisments