Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. asp.net role manager

asp.net role manager

Scheduled Pinned Locked Moved ASP.NET
csharpasp-netdatabasecomquestion
7 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • E Offline
    E Offline
    eyeseetee
    wrote on last edited by
    #1

    Hi Currently the default database for the asp.net login control stores the lastactivitydate for the user, i.e the last time they logged in using the login control. Is there a way to record each time they logged into the database? thanks

    Deliver yesterday, code today, think tomorrow. "http://www.heuse.com/cphumor.htm"

    B 1 Reply Last reply
    0
    • E eyeseetee

      Hi Currently the default database for the asp.net login control stores the lastactivitydate for the user, i.e the last time they logged in using the login control. Is there a way to record each time they logged into the database? thanks

      Deliver yesterday, code today, think tomorrow. "http://www.heuse.com/cphumor.htm"

      B Offline
      B Offline
      bcozican
      wrote on last edited by
      #2

      The asp.net login control uses the MembershipProvider to authenticate the user. Using the System.Web.Security.Membership.ValidateUser() method to authenticate the user will automatically update the lastactivitydate field when authenticating the user.

      E 1 Reply Last reply
      0
      • B bcozican

        The asp.net login control uses the MembershipProvider to authenticate the user. Using the System.Web.Security.Membership.ValidateUser() method to authenticate the user will automatically update the lastactivitydate field when authenticating the user.

        E Offline
        E Offline
        eyeseetee
        wrote on last edited by
        #3

        So to repeat my question, is there a way to log in the database a new record each time a user logs in?

        Deliver yesterday, code today, think tomorrow. "http://www.heuse.com/cphumor.htm"

        B 1 Reply Last reply
        0
        • E eyeseetee

          So to repeat my question, is there a way to log in the database a new record each time a user logs in?

          Deliver yesterday, code today, think tomorrow. "http://www.heuse.com/cphumor.htm"

          B Offline
          B Offline
          bcozican
          wrote on last edited by
          #4

          Sure, if you are using the login control then implement the Authenticate event of the Login control. Else do it whereever you are authenticating your user. I think the code below does what you want to accomplish: protected void Login1_Authenticate(object sender, AuthenticateEventArgs e) { string Username = this.Login1.UserName; string Password = this.Login1.Password; if (Membership.ValidateUser(Username, Password)) { Audit.Login.Log(Username, Audit.Login.eStatus.Success, Audit.Login.eSource.AdminSite); e.Authenticated = true; } else { Audit.Login.Log(Username, Audit.Login.eStatus.Fail, Audit.Login.eSource.AdminSite); e.Authenticated = false; } } Hope this helps.

          E 1 Reply Last reply
          0
          • B bcozican

            Sure, if you are using the login control then implement the Authenticate event of the Login control. Else do it whereever you are authenticating your user. I think the code below does what you want to accomplish: protected void Login1_Authenticate(object sender, AuthenticateEventArgs e) { string Username = this.Login1.UserName; string Password = this.Login1.Password; if (Membership.ValidateUser(Username, Password)) { Audit.Login.Log(Username, Audit.Login.eStatus.Success, Audit.Login.eSource.AdminSite); e.Authenticated = true; } else { Audit.Login.Log(Username, Audit.Login.eStatus.Fail, Audit.Login.eSource.AdminSite); e.Authenticated = false; } } Hope this helps.

            E Offline
            E Offline
            eyeseetee
            wrote on last edited by
            #5

            bcozican wrote:

            Audit.Login.Log(Username, Audit.Login.eStatus.Success, Audit.Login.eSource.AdminSite);

            What does the Audit stand for? Do I have to delcare this else where in my class?

            Deliver yesterday, code today, think tomorrow. "http://www.heuse.com/cphumor.htm"

            B 1 Reply Last reply
            0
            • E eyeseetee

              bcozican wrote:

              Audit.Login.Log(Username, Audit.Login.eStatus.Success, Audit.Login.eSource.AdminSite);

              What does the Audit stand for? Do I have to delcare this else where in my class?

              Deliver yesterday, code today, think tomorrow. "http://www.heuse.com/cphumor.htm"

              B Offline
              B Offline
              bcozican
              wrote on last edited by
              #6

              The .Net Membership doesnt have build in auditing so you will have to create a log table and classes to log data in it yourself. Audit.Login.Log() is my own function that I created to log the audit entry.

              E 1 Reply Last reply
              0
              • B bcozican

                The .Net Membership doesnt have build in auditing so you will have to create a log table and classes to log data in it yourself. Audit.Login.Log() is my own function that I created to log the audit entry.

                E Offline
                E Offline
                eyeseetee
                wrote on last edited by
                #7

                Ah ok. Thanks for that.I will give it a go.

                Deliver yesterday, code today, think tomorrow. "http://www.heuse.com/cphumor.htm"

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups