Solved

Utilizing client URL information?

Posted on 2002-06-10
10
179 Views
Last Modified: 2013-12-24
I have a need to check if a client is accessing our site from the internet or our intranet. I am running IIS 2000 Server and ColdFusion 5.0 server in the DMZ. I would like to compare the client URL to our known network URLs and put an "CFIF" clause. If the client is an intranet client I want to display different text than if the client is an internet client. Does anyone have a CF code or JavaScript sample that would do this?
0
Comment
Question by:apwbe
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 5
10 Comments
 
LVL 19

Expert Comment

by:cheekycj
ID: 7068673
Client's URL or IP address?  I don't think can simply access the Client's URL.

What you should do is use
CGI.remote_host or CGI.remote_addr

These will return the client's IP address.

Now you can use these to validate the clients connecting to your site instead of the URLs.

If you must URLs you can use the IP address to do a reverse DNS lookup and get the server name and then check it.

Another option, the better way to do this... is to use a reverse proxy on your server.  You can setup a reverse proxy to allow/deny various ip addresses or subnets.  This is easy to setup and a lot better than using code.

HTH,
CJ



0
 

Author Comment

by:apwbe
ID: 7068683
I am sorry. What I need is to compare a substring (the first 6 characters) of the client IP address. I have one CF page that needs to know if the client is internet or intranet as different text will be shown. Basicaly:

If IP.sub(0,5) = 180.40
    "you are Intranet"
else
    "Your are Internet"
End If

I know the syntex is goofy but  I hope you get the idea. I do not want to limit a whole page, just make a decision based on the client IP.

I do not know if a reverse proxy will do what I wnat it to do.

what do you think?
0
 
LVL 19

Expert Comment

by:cheekycj
ID: 7068702
try this:
<cfif Left(CGI.remote_addr, 6) IS "180.40">
     You are accessing this page from the intranet.
<cfelse>
     You are accessing this page from the internet.
</cfif>

or try this:
<cfif FindNoCase("180.40", CGI.remote_addr, 1) EQ 1>
     You are accessing this page from the intranet.
<cfelse>
     You are accessing this page from the internet.
</cfif>

HTH,
CJ
0
Do you have a plan for Continuity?

It's inevitable. People leave organizations creating a gap in your service. That's where Percona comes in.

See how Pepper.com relies on Percona to:
-Manage their database
-Guarantee data safety and protection
-Provide database expertise that is available for any situation

 

Author Comment

by:apwbe
ID: 7068750
The FindNoCase seems to work. Here is what I am trying.

<cfif FindNoCase("10", CGI.remote_addr, 1) EQ 1>
    You are accessing this page from the intranet
<cfelseif FindNoCase("192.168", CGI.remote_addr, 1) EQ 1>
     You are accessing this page from the intranet
<cfelseif FindNoCase("172.16", CGI.remote_addr, 1) EQ 1>
     You are accessing this page from the intranet
<cfelse>
    You are accessing this page from the internet.
</cfif>

I will test it from home later tonight. If I wanted to display the IP address, how whould I do that?
0
 
LVL 19

Expert Comment

by:cheekycj
ID: 7068758
eq 1 means it starts with that address, so do you have 10 as a start of the ip addy?

to display the address add this:

<cfoutput>Client's IP Address: #CGI.remote_addr#</cfoutput>

CJ
0
 

Author Comment

by:apwbe
ID: 7068759
The FindNoCase seems to work. Here is what I am trying.

<cfif FindNoCase("10", CGI.remote_addr, 1) EQ 1>
    You are accessing this page from the intranet
<cfelseif FindNoCase("192.168", CGI.remote_addr, 1) EQ 1>
     You are accessing this page from the intranet
<cfelseif FindNoCase("172.16", CGI.remote_addr, 1) EQ 1>
     You are accessing this page from the intranet
<cfelse>
    You are accessing this page from the internet.
</cfif>

I will test it from home later tonight. If I wanted to display the IP address, how whould I do that?
0
 

Author Comment

by:apwbe
ID: 7068765
Yes,

I have one that starts with a 10.x.x.x that I have to compare then I have one that starts with 192.168.x.x that I have to compare and lastly 172.16.x.x hat I have to compare. If the IP address starts with any of these then it is intranet else internet.

0
 
LVL 19

Accepted Solution

by:
cheekycj earned 150 total points
ID: 7070174
how did it work out?

CJ
0
 

Author Comment

by:apwbe
ID: 7071359
cheekyci,

Thanks for the help. Actually oth sample seem to work for what I want. Keep up the excellent work and thanks again.

Good Luck,

Warren
0
 
LVL 19

Expert Comment

by:cheekycj
ID: 7071369
Glad I could help and thanx for the "A"

CJ
0

Featured Post

Connect further...control easier

With the ATEN CE624, you can now enjoy a high-quality visual experience powered by HDBaseT technology and the convenience of a single Cat6 cable to transmit uncompressed video with zero latency and multi-streaming for dual-view applications where remote access is required.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you don't have the right permissions set for your WordPress location in IIS, you won't be able to perform automatic updates. Here's how to fix the problem.
When it comes to showing a 404 error page to your visitors, you do not want that generic page to show, and you especially do not want your hosting provider’s ad error page to show either. In this article, I will show you how to enable the custom 40…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses

617 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question