Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeOur CommunityOur CommunityGeneral Discuss...General Discuss...how to get user IPhow to get user IP
Previous
 
Next
New Post
11/15/2007 7:28 AM
 

Hello,

 

Is it possible to get the last user ip from the user was logged in?

 

Thank you in advance,

Yael

 
New Post
11/15/2007 8:53 AM
 

It is indeed possible to pull this information from the EventLog table.  However, I do not know of a direct query to get to that information.  The only items available for the EventLog are: AddEventLog, DeleteEventLog, GetEventLogByGUID, GetEventLogPendingNotif, GetEventLogPendingNotifConfig, PurgeEventLog, UpdateEventLogPendingNotif.

You would have to build your own module that includes a query to the EventLog table.

If you are using SQL Server 2005, this Stored Procedure would work.  It will give you the last IP number and the date/time it occurred.  You can also do this for SQL Server 2000, but the XML is done differently, I think.

CREATE PROCEDURE [dbo].[ModuleName_GetLastIpNumberForUser]
 @UserName NVARCHAR(100),
 @PortalId INT
AS
BEGIN
 SET NOCOUNT ON;
 
 DECLARE @Xml XML, @LogDate DATETIME;
 SELECT TOP 1 @Xml = CAST(el.[LogProperties] AS XML), @LogDate = el.[LogCreateDate] 
 FROM [EventLog] el
 WHERE (el.[LogUserName] = @UserName AND el.[LogPortalID] = @PortalId)
 AND el.[LogTypeKey] = 'LOGIN_SUCCESS'
 ORDER BY el.[LogCreateDate] DESC;
 SELECT @Xml.value('(/LogProperties/LogProperty/PropertyValue)[1]', 'NVARCHAR(50)'), @LogDate;
END

Will Strohl

Upendo Ventures Upendo Ventures
DNN experts since 2003
Official provider of the Hotcakes Commerce Cloud and SLA support
 
New Post
11/15/2007 8:54 AM
 

afaik this is not stored, you need to modify the login procedure in the core framework


Cheers from Germany,
Sebastian Leupold

dnnWerk - The DotNetNuke Experts   German Spoken DotNetNuke User Group

Speed up your DNN Websites with TurboDNN
 
New Post
11/15/2007 8:57 AM
 

Sebastian Leupold wrote

afaik this is not stored, you need to modify the login procedure in the core framework

Sebastian, wouldn't my procedure work?  I just checked the event log, and the information is there (unless it has been pulled out since v4.05.03).


Will Strohl

Upendo Ventures Upendo Ventures
DNN experts since 2003
Official provider of the Hotcakes Commerce Cloud and SLA support
 
New Post
11/15/2007 9:36 AM
 

Using this query:

DECLARE @UserName NVARCHAR(100), @PortalId INT;
SET @UserName = '<SOME_USERNAME>';
SET @PortalId = 0;
SELECT TOP 1 el.[LogGUID],el.[LogTypeKey],el.[LogConfigID],el.[LogUserID]
 ,el.[LogUserName],el.[LogPortalID],el.[LogPortalName],el.[LogCreateDate]
 ,el.[LogServerName],el.[LogProperties],el.[LogNotificationPending]
FROM [dbo].[EventLog] el
WHERE (el.[LogUserName] = @UserName AND el.[LogPortalID] = @PortalId)
AND el.[LogTypeKey] = 'LOGIN_SUCCESS'
ORDER BY el.[LogCreateDate] DESC

You get this output (but your data will be different, and I replaced obvious values):

LogGUID                              LogTypeKey                          LogConfigID LogUserID   LogUserName                                        LogPortalID LogPortalName                                                                                        LogCreateDate           LogServerName                                      LogProperties                                                                                                                                                                                                                                                    LogNotificationPending
------------------------------------ ----------------------------------- ----------- ----------- -------------------------------------------------- ----------- ---------------------------------------------------------------------------------------------------- ----------------------- -------------------------------------------------- ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ----------------------
<SOME_GUID>                          LOGIN_SUCCESS                       7           2           <SOME_USERNAME>                                    0           <SOME_PORTAL_NAME>                                                                                   2007-11-12 10:08:28.673 <SOME_SERVER_NAME>                                 <LogProperties><LogProperty><PropertyName>IP</PropertyName><PropertyValue>127.0.0.1</PropertyValue></LogProperty></LogProperties>                                                                                                                                NULL

Using the Stored Procedure from above, you get this output (but your data will be different, and I replaced obvious values):

                                                   
-------------------------------------------------- -----------------------
127.0.0.1                                          2007-11-12 10:08:28.673

Will Strohl

Upendo Ventures Upendo Ventures
DNN experts since 2003
Official provider of the Hotcakes Commerce Cloud and SLA support
 
Previous
 
Next
HomeHomeOur CommunityOur CommunityGeneral Discuss...General Discuss...how to get user IPhow to get user IP


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out