Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How Do I only Allow certain pc to access my page

Status
Not open for further replies.

choohean

Technical User
Jan 15, 2002
57
MY
I have created some asp page! How do I only allow certain pc to access my asp page within the intranet?
 
The IP address of the remote PC is available to be checked.
So if you know the IP addresses of these PCs that are allowed to access the page, you could check for them.


Something like this, as a really brief example. Adjust to suit.

theIP = request.servervariables("REMOTE_ADDR")
If theIP <> &quot;this&quot; or theIP <> &quot;that&quot; Then
response.write(&quot;You're Not Allowed!!&quot;)
End If
 
How if the Ip address is not fix! And also I have tried the solution you given, the IP address comes out are different from the IP address that I have!

Is just like that, my PC having 141.253.146.110 as IP

but when using theIP = request.servervariables(&quot;REMOTE_ADDR&quot;)

the IP address comes out different!

why?
 
If the IP is not fixed, then forget this approach.

You need something that can distinguish one physical PC from another. I wonder if the computer name, or the hardware network card address, available?

 
I don't think the MAC address (is the network address) is available directly fron ASP. But with the free ASPExec server plugin from ServerObjects, then the follwomg code should work.


<%
Dim Executor
Dim Result
Dim MAC
Set Executor = Server.CreateObject(&quot;ASPExec.Execute&quot;)
Executor.Application = &quot;nbtstat.exe&quot;
Executor.Parameters = &quot;-A &quot; & Request.ServerVariables(&quot;REMOTE_ADDR&quot;)
Result = Executor.ExecuteDosApp
Set Executor = Nothing
MAC = Mid(Result, Instr(Result, &quot;MAC Address&quot;) + 14, 17)
Response.Write MAC
%>
 
If I using the solution given by u!!

the output will be 00-10-B5-88-B2-E4 and not ip addres!
can i use this to check?!?
 
Well, yeah, every PC will give you a different MAC. So you can add code similar to what we mentioned above:

If MAC <> &quot;00-10-B5-88-B2-E4&quot; Then
response.write(&quot;You're Not Allowed!!&quot;)
End If
 
I have tried in 2 different PC but the result come out the same!

That's mean I get the same about when I using this page in different PC!
 
Hmmm, okay then I guess it picks up the MAC address from the server instead of the client. I thought it would be the client. Sorry.

So I guess I can't think of a way to limit to a specific machine.

Anyhow, I think most people would be more comfortable building a password-based approach to controlling access to the application.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top