asp.net role manager
-
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"
-
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"
-
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.
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"
-
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"
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.
-
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.
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"
-
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"
-
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.
Ah ok. Thanks for that.I will give it a go.
Deliver yesterday, code today, think tomorrow. "http://www.heuse.com/cphumor.htm"