Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Utilizing client URL information?

Posted on 2002-06-10
10
Medium Priority
?
180 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
Moving data to the cloud? Find out if you’re ready

Before moving to the cloud, it is important to carefully define your db needs, plan for the migration & understand prod. environment. This wp explains how to define what you need from a cloud provider, plan for the migration & what putting a cloud solution into practice entails.

 

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 600 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

Building an interactive eFuture classroom

Watch and learn how ATEN provided a total control system solution including seamless switching matrix switch, HDBaseT extenders, PDU, lighting control to build an interactive eFuture classroom.

Question has a verified solution.

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

Most ColdFusion developers get confused between the CFSet, Duplicate, and Structcopy methods of copying a Structure, especially which one to use when. This Article will explain the differences in the approaches with examples; therefore, after readin…
One of the typical problems I have experienced is when you have to move a web server from one hosting site to another. You normally prepare all on the new host, transfer the site, change DNS and cross your fingers hoping all will be ok on new server…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

722 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