logon time of a window user ?

asifali

New member
Joined
Apr 11, 2020
Messages
3
Programming Experience
1-3
Hi Every body,
I am new in c#, I have to make an application in which I have to get the logon information of all computers on my local Area network. But I am stuck.
please provide me c# code in which I can get logon information of all computers on my Local area network and store it into my database.

It will be really appreciated.
 
A few things here. Firstly, this is not generally a place to get people to just write your code for you. We generally try to help you become a better programmer and the best way to learn is to do. We will certainly help with specific issues but, as far as we can tell from your post, you haven't actually tried to do anything so you can't have encountered any issues yet. If you don't know how to do something then the first step should be to try to find information about doing that thing, not asking someone else to do it for you.

Secondly, you need to break any problem down into its smallest possible constituent parts and then tackle each part independently. For instance, in order to get any information from each machine on a network, you need to be able to determine what machines there are on that network. That should be the first thing you try to do so get researching that. A good second step might be to get the desired information from the local machine. Etc.

Finally, you need to provide a FULL and CLEAR explanation of the problem in your post. Your post says "logon information" and I didn't really know what that meant until I saw "logon time" in the title. You post should be complete and unambiguous. If we have to guess anything then we can guess wrong and that's a waste of everyone's time. That description should also include what you've tried and what happened when you tried it. If all you've tried is unsuccessful web searches for information then tell us that, including the sorts of terms you've been searching for. If we can see that the problem is that you're searching for useless keywords then we can set you on the right path there and then you can find useful information that will help you at least try to write code for yourself. If you encounter a specific issue while writing that code, we can help with that.
 
Thanks for your reply. Sorry I should have to share attempts make by me. Here is my code,

//Get computer name
string MachineName = System.Environment.GetEnvironmentVariable("COMPUTERNAME");
textBox1.Text = MachineName;

//Get User name
string UserName = Environment.UserName;
textBox2.Text = UserName;

//get process id and and application name
System.Diagnostics.Process p = System.Diagnostics.Process.GetCurrentProcess();
int id = p.Id;
string name = p.ProcessName;
textBox3.Text = Convert.ToString(id);
textBox4.Text = name;
//// get ip address.
IPHostEntry hostname = Dns.GetHostEntry(textBox1.Text);
IPAddress[] ip = hostname.AddressList;
textBox5 .Text = ip[0].ToString();

Every part of my code is commented and showing his functionality. Now my requirement to get logon time of the user on same machine. Ip address or machine name could be used as parameter to get user logon time. Give help to get user logon time. Hope, It clear now.
Thanks.
 
codetags-gif.884
 
Presumably all your computers on the local network are all Windows machines, otherwise, you'll need multiple implementations for different OSes for retrieving the logon time: One for Windows, another for Linux, and presumably something almost Linux-like for MacOS.

Anyway, assuming all your computers are Windows machines, are they all joined to the same Active Directory domain, or are you just using Windows workgroups. If you are using an Active Directory domain, you could simply query the Active Directory to see what time that user logon and from what computer. If you are not using Active Directory, then you'll need go hit each machine and query the event log on each machine to see when a user has logged on. Do you have admin rights on each machine to do that kind of query?

Also do you need just when the user last logged on? Or are you looking for all the instances that user has ever logged on to a machine?
 
Presumably all your computers on the local network are all Windows machines, otherwise, you'll need multiple implementations for different OSes for retrieving the logon time: One for Windows, another for Linux, and presumably something almost Linux-like for MacOS.

Anyway, assuming all your computers are Windows machines, are they all joined to the same Active Directory domain, or are you just using Windows workgroups. If you are using an Active Directory domain, you could simply query the Active Directory to see what time that user logon and from what computer. If you are not using Active Directory, then you'll need go hit each machine and query the event log on each machine to see when a user has logged on. Do you have admin rights on each machine to do that kind of query?

Also do you need just when the user last logged on? Or are you looking for all the instances that user has ever logged on to a machine?

Thanks for your reply. Yes, All machines consist of Windows operating system and there is no active directory domain so PC's are on workgroup.
Actually I want, when a user login to windows; User name and time of logon should be stored in database and when user open applications log should generate consist of application name.
@Skydiver Thanks again for your reply.
 
Oh! If that is all you wanted, you could take advantage of the different triggers available to you using the Task Scheduler built into Windows. I know there is a trigger for when someone logs on. I believe there is a trigger for when applications are started. Just add scheduled task(s) for those triggers.
No need to go query each machine, specially since there is no way that I can think of to query a machine what applications have run on it (unless you happen to be running some nannyware like Privilege Guard or Aeternity which logs apps).
 
Back
Top Bottom