Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Development Tools
 ASP.NET
 Log User IP Address

Author  Topic 

samtoffa
Yak Posting Veteran

60 Posts

Posted - 2004-08-19 : 09:10:09
I want to be able to log users' IP addresses into a table in my SQL Server database. I am using Dreamweaver to create active server pages driven by VB script. Anyone got a suitable lump of code to do the job?
Cheers,
Sam

ehorn
Master Smack Fu Yak Hacker

1632 Posts

Posted - 2004-08-19 : 09:36:21
You can obtain the users ip from the SERVERVARIABLES(REMOTE_ADDR)

http://www.asp-help.com/objects/intr5vsj.asp
Go to Top of Page

samtoffa
Yak Posting Veteran

60 Posts

Posted - 2004-08-19 : 10:38:52
Great. That sounds like just what I need.
cheers,
Sam
Go to Top of Page

samtoffa
Yak Posting Veteran

60 Posts

Posted - 2004-08-19 : 11:29:11
Is there any way to do this that is 'all server-side', i.e. a trigger on a table causes the logging of the IP address of the person that queried the table without going via and active server page?
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2004-08-19 : 13:32:40
Not if the user is using an ASP web site - as far as SQL is concerned the connected user is IIS!

We get around this by having something trap the first page (if you are using the session object then GLOBAL.ASA would do, or something similar), grabbing the IP address (and possibly UserAgent / Referrer etc.) and storing them in the database together with the Session ID. Then you need to pass the Session ID to your SQL to be stored along with the data, and join that to the "Session Data" you stored at the start of the session.

(We actually drop a cookie with a GUID in it as the "session ID" and use that instead of the ASP Session, but its the same idea)

Kristen
Go to Top of Page

samtoffa
Yak Posting Veteran

60 Posts

Posted - 2004-08-19 : 14:55:05
Thanks,I'll try the techniques that you've suggested.
Cheers,
sam
Go to Top of Page

samuelhon
Starting Member

5 Posts

Posted - 2004-08-31 : 05:54:40
Hi

If you're just logging who requested a webpage and are using IIS, then you can use the IIS logging features.

[url]http://support.microsoft.com/default.aspx?sd=tech&scid=kb;EN-US;q300390[/url]

If you're looking for more detailed info, then this method probably wont be good enough

Sam

Go to Top of Page

samtoffa
Yak Posting Veteran

60 Posts

Posted - 2004-08-31 : 08:12:18
Thanks for your input Sam. The problem I have is that someone else is hosting IIS for me and I just want to be able to look at who has been accessing certain data via a simple .asp interface. I have found a way to do it that isn't fantastic but it will do OK.
Sam
Go to Top of Page
   

- Advertisement -