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

HomeHomeDNN Open Source...DNN Open Source...Provider and Extension ForumsProvider and Extension ForumsAuthenticationAuthenticationLast Login Date - Not changingLast Login Date - Not changing
Previous
 
Next
New Post
1/31/2006 11:26 PM
 

Angel,

I will have to disagree with you on this issue.
 
We are not interested in the last date/time the user logged into the domain, we are interested in the last date/time the user logged into the DNN portal.  These are 2 different things.  A user could log into the domain a 8:30a, but not log into the DNN portal until 11:35a.

The Authentication code built into DNN *simply* needs to set the LastLoginDate field in the aspnet_membership table.  I have not been able to find the correct place in the code where this update should take place.

This is importabnt for those sites that need this information to meet their internal security requirements.  I am hoping that a core team member will confirm this when they get time.

I will continue to look for the correct solution...

mikez

 
New Post
3/10/2006 9:17 AM
 

mikez,

   I of course have the same problem.  Windows users can access the intranet portal using Windows integrated security as long as their domain\username is a user in the portal.  However, I wanted to use the lastlogindate to display "new" and "updated" icons next to items that had changed since their last visit.  I wanted to retrieve and save off the lastlogindate in a session variable at the beginning of the session (before it was updated, so if a user last logged on 3 days ago, I would have access to this info for the entire session).  I added a session_start handler to global.asax.vb to take care of setting the session variable, however, as you noticed, the lastlogindate was not being updated, so I added code there to update the lastlogindate after setting the session variable.  Here's the code.  Hope it helps.  Haven't tested this with forms authentication, so I'm not sure if it will work properly with forms authentication.

Sub Session_Start(ByVal sender As Object, ByVal e As EventArgs)

   If Not CType(HttpContext.Current.Items("UserInfo"), UserInfo) Is Nothing Then

      Session("LastLoginDate") = CType(HttpContext.Current.Items("UserInfo"), UserInfo).Membership.LastLoginDate

   Else

      Session("LastLoginDate") = Date.Now

   End If

   'Update lastlogindate

   Dim objmembershipuser As MembershipUser = Microsoft.ScalableHosting.Security.Membership.GetUser(True)

   objMembershipUser.LastLoginDate = Date.Now

   Microsoft.ScalableHosting.Security.Membership.UpdateUser(objMembershipUser)

End Sub

boilermaker

 
New Post
3/10/2006 1:14 PM
 

I found a problem with the above approach if the user is a superuser.  There were two users with the same username in the aspnet_Membership table, one with the applicationid corresponding to an applicationname of -1 and the other with an applicationid corresponding to the portal applicationname of 0.  When the user is a superuser, the applicationname is set to -1, and all user lookups look up the user entry in aspnet_Membership corresponding to this applicationname.  So I deleted the record from the aspnet_Membership table with the username of the superuser that corresponded to the applicationname of 0 (the portal), leaving only the record corresponding to the superuser and the applicationname of -1, then I changed the code above as shown below.  It seems to work now for my purposes.  Anywhere in the app I want to use the lastlogindate, I use the Session("LastLoginDate") variable.  I could not use the lastlogindate of the user object carried in the context, as this user object appears to be re-created occasionally and the lastlogindate is therefore updated to the most recent logon, whereas I wanted the most recent logon before this "session" so I could continue to display the "new" and "updated" icons until the user was done looking around (session ended).

I do not completely understand everything that occurs regarding the user stuff (why does DNN set the appname to -1 for a superuser?), and this is definitely a hack, but it appears to be working for my purposes.  Hope it helps you.

   Sub Session_Start(ByVal sender As Object, ByVal e As EventArgs)

   If Not CType(HttpContext.Current.Items("UserInfo"), UserInfo) Is Nothing Then

   Session("LastLoginDate") = CType(HttpContext.Current.Items("UserInfo"), UserInfo).Membership.LastLoginDate

   Else

   Session("LastLoginDate") = Date.Now

   End If

   'Update lastlogindate

   Dim objmembershipuser As MembershipUser = Microsoft.ScalableHosting.Security.Membership.GetUser(True)

   If objmembershipuser Is Nothing Then

   Dim OriginalApplicationName As String = Globals.GetApplicationName

   'could be a SuperUser, try super user application name

   Globals.SetApplicationName(Globals.glbSuperUserAppName)

   objmembershipuser = Membership.GetUser

   objmembershipuser.LastLoginDate = Date.Now

   Microsoft.ScalableHosting.Security.Membership.UpdateUser(objmembershipuser)

   'Reset the Application Name

      Globals.SetApplicationName(OriginalApplicationName)

   Else

      objmembershipuser.LastLoginDate = Date.Now

      Microsoft.ScalableHosting.Security.Membership.UpdateUser(objmembershipuser)

   End If

End Sub

 
New Post
4/17/2006 6:38 PM
 

Sorry for the late reply.
We ran into the same problem on SuperUser accounts.  We took a different approach to solving the problem for now.  Since we already had a Splash page it was an easy matter to add the following code to Page_Load.

Since there will be Membership changes to the DNN3.3/4.1 code we have decided to let this code run and deal with the new version.  From what we can read there are no changes coming to the authentication code for DNN3.3.  We'll take a look again after the new release.

If Not Page.IsPostBack Then

   'do not run if SuperUser - Runs under Application -1 & will throw an error
   If Not UserInfo.IsSuperUser Then
      
Dim objUsers As New UserController
      
Dim objUser As UserInfo = objUsers.GetUserByUsername(PortalSettings.PortalId, UserInfo.Membership.Username)

      'get the ApplicationName - objMembershipUser.Provider.ApplicationName
      
Dim objMembershipUser As AspNetSecurity.MembershipUser
      objMembershipUser = AspNetSecurity.Membership.GetUser(objUser.Membership.Username)

      'Execute an existing stored procedure to set LastLoginDate
      
SqlHelper.ExecuteNonQuery(Config.GetConnectionString, "aspnet_Membership_UpdateLastLoginAndActivityDates",    
      objMembershipUser.Provider.ApplicationName, objUser.Membership.Username, PortalSettings.TimeZoneOffset)
   End If
End If

mikez

 
Previous
 
Next
HomeHomeDNN Open Source...DNN Open Source...Provider and Extension ForumsProvider and Extension ForumsAuthenticationAuthenticationLast Login Date - Not changingLast Login Date - Not changing


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