Solved

Utilizing client URL information?

Posted on 2002-06-10
10
175 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
Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

 

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

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

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

This is a guide to setting up a new WHM/cPanel Server to be used for web hosting accounts. It is intended for web hosting company administrators and dedicated server owners. For under $99 per month (considering normal rate of Big Data Cetnters like …
Introduction This article explores the design of a cache system that can improve the performance of a web site or web application.  The assumption is that the web site has many more “read” operations than “write” operations (this is commonly the ca…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

738 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