How to identify a user's location

69 Views Asked by At

I have a Classic ASP application that several users log into from several different physical store locations. They are all hitting the same database and web server of course. But I would like to know what location a user is login in from. I thought of perhaps reading the local computer name, but I'm reading this isn't a good method for security reasons. Is there a way that I can determine what physical computer a user has logged into the application from? (Users are using Edge and Chrome browsers in the company and stores are within a mile radius of each other.)

What I am trying to do is filter a set of options that are only relevant in the application if the user has logged in from a specific physical store location. The catch is that users can work out of any store in any given weekday. So, I'm thinking I have to find something that identifies the physical computer that they are logging in from.

1

There are 1 best solutions below

5
mplungjan On

Update based on comment

You need the users to log into the server with userID and store name.

Save it in sessions and log them out if they are logged in at another location or computer (i.e. do not have a session on that computer).


Older answer


The fastest, since you can control the users, is to determine if the stored have a fixed public IP address or, if not fixed, that each store has a known range of IP addresses.

If so, you can, on the server, test the store by IP address (range) by code looking like this

<%
Dim clientIPAddress
clientIPAddress = Request.ServerVariables("REMOTE_ADDR")
Response.Write("Client IP Address: " & clientIPAddress)
%>

Then for example it could look like this (192.168 is internal IP addresses, you will see other addresses if they come via the internet)

<%
Dim userIP, storeLocation
userIP = Request.ServerVariables("REMOTE_ADDR")

' Example IP addresses for different stores
Dim store1IP, store2IP
store1IP = "192.168.1.1" ' Replace with actual store 1 IP address
store2IP = "192.168.1.2" ' Replace with actual store 2 IP address

' Check which store the user is from
Select Case userIP
    Case store1IP
        storeLocation = "Store 1"
    Case store2IP
        storeLocation = "Store 2"
    Case Else
        storeLocation = "Unknown"
End Select

' Output or use the store location
Response.Write("User is from: " & storeLocation)

' Further logic based on storeLocation
If storeLocation = "Store 1" Then
    ' Logic specific to Store 1
ElseIf storeLocation = "Store 2" Then
    ' Logic specific to Store 2
Else
    ' Default logic or error handling
End If
%>