Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 180
  • Last Modified:

Getting NT Status - logged on / off or locked

How can I tell if a computer has someone logged in? I need to write a program that tells if someone is at their desk, the idea being that if they are, they're most likely to also be logged in and not be logged out or locked. I need a "yes" answer from the program for a logged in and a "no" answer for any other state. I can then write this to a web page in my usual way.

Cheers

Dave
0
wierd_dave
Asked:
wierd_dave
  • 5
  • 4
  • 2
  • +2
1 Solution
 
inprasCommented:
I think U need to have an adapater installed on the end m/c which monitors the events on the end m/c logs them and sends to server (for this U can use sockets)..
Hope this helps
0
 
shaigCommented:
What if a user is logged in, but away from his computer?

Try a different view:
Detect keyboard and mouse events. If idle for more then a defined time, then declare user as 'away'.   ICQ uses a simulare mechanism.

You can implement this using Win32 hooks.
0
 
wierd_daveAuthor Commented:
I can handle him being away! I'm having to put up with an endless stream of students looking for a certain research assistant, so if I can put whether he's in or not on a web page, I'll be a happy chappie.

Would the computer being locked affect the operation of a program?

Dave
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
jkrCommented:
The most compatible way for all MS platforms would be to enumerate the entries in 'HKEY_USERS' - see http://www.sysinternals.com/misc.htm#loggedon for a source code sample...
0
 
wierd_daveAuthor Commented:
Looking at this program, it only checks if the computer has a user loged in or not, ragardless of whether it is locked or not. We very rarely log off in this office, preferring to lock so we can still access each others resources.
A locked machine is the best indication that we are not in.
If it's not locked and unused, we've popped to the coffee machine.
If it's logged out, we're probably rebooting or logging back in as an administrator.
If it's locked we've left the building for whatever reason.
0
 
jkrCommented:
Err - your question was "How can I tell if a computer has someone logged in?".

My answer was the answer to this very question... It's not good practice here to ask questions, reject correct answers along with telling 'no, I wanted to know something else'
0
 
wierd_daveAuthor Commented:
OK, I don't appear to have been as clear as I thought I had been. When I said "I need a "yes" answer from the program for a logged in and a "no" answer for any other state." I meant that if the machine is logged in and not locked, then I can assume someone is sat there working. If it is logged off or is logged in to, but has been locked, they probably are not working here.

I know what I meant, I just didn't say it quite right.

Dave
0
 
shaigCommented:
I still think this is a bad mechanism.
The best way to tell if a user is using his compuetr is to check just that: keyboard and mouse activity.

How does the suggested mechanizm deal with a user that shuts his computer down (vecation, sick, etc.).
0
 
wierd_daveAuthor Commented:
I'm working on this activity monitor right now. If the mouse hasn't moved or the keyboard been touched in 15 minutes say, I'll log him as been out.
If he logs out the program will recieve a quit message and he can be instantly log as away.
Indeed it seems simpler this way.
0
 
shaigCommented:
Yap, thats the idea.
0
 
jhanceCommented:
To detect if there is a logged on interactive user, enumerate the window stations until you find WinSta0.  Then use that handle to enumerate the desktops.  If you find WinSta0\default, then there is an interactive user logged in.  If this desktop doesn't exist, then there is no interactive user logged in.
0
 
shaigCommented:
So, what will it be wierd dave?
0
 
wierd_daveAuthor Commented:
I went for the windows hooks. Placed in a dll they should be able to log all activity from what MSDN tells me.

This has been a thread full of good stuff as far as I'm concerned - cheers to all.

Dave
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 5
  • 4
  • 2
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now