Reputation: 553
I'm writing an application where users use my program to log into different PLCs. All the PLCs use the same program to login. Many people remote into a server to access what they need. The application works fine and I can track who logged on using Environment.UserName
.
Now what has happened is users are allowed to log on multiple times for certain cases and still use my application. This has caused some problem with my tracking because if they log off the PLC in one session, the application thinks they have logged off both sessions.
What I need now to have the accuracy I want is the User ID that you can see when you you pull up "Task Manager" and look under the "Users" Tab.
I have looked into WindowsIdentity.GetCurrent().
and Environment.
I don't know if I missed it, overlooked it, suck at googling, but I don't know of a way that I can retrieve this number through VB.NET.
If you are wondering why I'm not using like PID or something to track the program, that is because I cannot. The process of the program that runs the PLCs runs in the background of the session, which mean I cannot access the PID or anything of that process.
Thanks
Upvotes: 0
Views: 1779
Reputation: 553
Finally had some time to do some digging.
Process.GetCurrentProcess().SessionId
This did the trick. Not sure why I struggled so much to find this, but i figured I would update this with an answer!
Cheers!
Upvotes: 1