3
Answers

how to know the username after logging out from the application in c#

Photo of omar ahmed

omar ahmed

16y
2.8k
1

Hi,All

I have a windows  application  in C#.NET 2005 that asks for username and password when logging in to the application .I need to create a log  for the user activities (i.e username,entry time,exit time ) to  know who was the user that was using the application in specific period and when he had entered,stayed, and closed the application.

I would appreciate if any one could  help me

thanks in advance

 

Answers (3)

0
Photo of John Penn
NA 3.1k 134.5k 16y
You can use a library such as log4net to do the grunt work, all you need to is call the log method at the appropriate times from within your app.
0
Photo of omar ahmed
NA 18 0 16y

Hi all

Thanks John Penn

 but what I need is to create users avtivities with in my appliction even if there is power failure so that I will be able to control the control users' activities (user 'xxx' has  transacted on ' TIME'  , dropped table at 'Time' ...etc)

I can know the user the user logged on from Wimdows account  using some code like
System.Security.Principal.WindowsIdentity user =
     System.Security.Principal.WindowsIdentity.GetCurrent();
Response.Write(user.Name);

but I need it in my own appliction's user account

how can I write the code in c# for the user logon  like the one in windows

I would prefer if u would write some few lines of  code of how this will take place.

tanx

0
Photo of John Penn
NA 3.1k 134.5k 16y
The FormClosing event of the main form will fire when the user tries to close the form.  Here you can write your "user has logged out" information to the application's log.