Tracking User Login IP Address

Tony Feltham asked on March 15, 2018 14:25

I would like to track the number of IP Addresses users are logging in from so that I can limit their login locations.

For example allow a user to login via up to 3 IP addresses (these could be any IP Address)

I can see that in the event log the IP Address is recorded and on login I could check this but there is no guarantee that the Event Log would not be cleared at some point, therefore losing this data.

Are user logins and the data associated with them stored anywhere else on the system? If so can you let me know the whereabouts (i.e. table names).

If not I will need to store all logins in a custom table with the required data I need and then process this data on login. If this is the case how can I find the IP Address of the login so that I can store it in this new custom table.

Many Thanks Tony

Recent Answers

Zach Perry answered on March 15, 2018 17:10

Not sure of any other tables, you might be able to do something with the marketing tools, not sure.

You can get the users IP address off the userinfo object: user.UserLastLogonInfo.IPAddress

0 votesVote for this answer Mark as a Correct answer

Peter Mogilnitski answered on March 16, 2018 01:42 (last edited on March 16, 2018 02:01)

You need to use Global Security Events Handler when users attempt to sign in on the website. In the handler, you can save IPs to your custom table/compare etc using Custom Table API.

You can probably use GeoLocation API to resolve IP to Location using AnalyticsContext.CurrentGeoLocation class

GeoLocation currentGeoLocation = GeoIPHelper.GetCurrentGeoLocation();
if (currentGeoLocation != null)
    var countryAndState = ValidationHelper.GetString(currentGeoLocation.CountryName, "");
    var ipCountryCode = ValidationHelper.GetString(currentGeoLocation.CountryCode, "");
    var ipRegion = ValidationHelper.GetString(currentGeoLocation.RegionName, "");
    var ipCity = ValidationHelper.GetString(currentGeoLocation.City, "");

And you do your analysis. If user logins every day from different country... :)

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.