Hello,
I purchased the Dynamic Login module and the main task that I'm trying to accomplish is, when the user logs in I want to check the last IP address that was used and recorded by DNN and if the timestamp on the last login is less than 24 hours, I need to make sure that the user is logging in from the same IP address as the previous one. I'm pretty sure the way to accomplish this is to use SQL Validation. I've written the query but for some reason, it doesn't seem to evaluate the ip address correctly. I'm not sure if it's something with my code or with the module. This is the SQL that I have. Any help with this would be greatly appreciated!!
IF ( SELECT LEN(LastIPAddress) FROM dbo.Users WHERE UserID = $(UserID) ) < 1 BEGIN SELECT IsValid = 1 END ELSE IF ( SELECT LEN(LastIPAddress) FROM dbo.Users WHERE UserID = $(UserID) ) > 1 BEGIN IF ( SELECT DATEDIFF(HOUR, LastModifiedOnDate, GETDATE()) FROM dbo.Users WHERE UserID = $(UserID) AND UserId NOT IN ( 1, 2 ) ) < 24 BEGIN DECLARE @IP AS VARCHAR(50) SELECT @IP = ( SELECT LastIPAddress FROM dbo.Users WHERE UserID = $(UserID) ) SELECT IsValid = CASE WHEN @IP = $(IPAddress) THEN 1 ELSE 0 END END ELSE BEGIN SELECT IsValid = 1 END END
|