How to check windows domain user status?

6,062

There is no built-in functionality to do any of the things you're asking for in either the server or client operating system, (and you're not going to see any new functionality moving from W2K to W2K3 on your servers). You're going to have to code something to get what you want.

With respect to the server computer, "logon" doesn't mean what you think it does. An "Interactive" logon on a client computer definitely has a starting time and an ending time. The "logon" from the client to remote server computers will depend on what the client is doing. Terminal Services logons from a client to a server are "Interactive" and share the properties of a client's own "Interactive" session.

I'm assuming that you probably want to know the duration of the "Interactive" session on a client computer. You can have a look at querying the Win32_LogonSession WMI class as a way to get that information.

I think you're thinking that you can use the event logs on a server computer to figure out when client computers go thru an "Interactive" logon. You can't.

Doing the initial domain authentication or accessing a "mapped" "drive" on a server computer from a client computer is a "Network" logon, and the times associated with the logon and logoff will relate to when the client begins to access the resource and when the client (or server) closes the connection for inactivity (or an "unmapping" or "Interactive" logoff of the user's client session).

You shouldn't think of "Domain Logons" or Microsoft File and Print sessions like SSH or TELNET sessions in having a fixed duration that begins when the user "logs on" and ends when the user "logs off". The connection to the server computer may come up and down during normal use of the client computer. Using the server-side event log to determine the duration of an "Interactive" session on a client computer is no good.

There's some sample code here to detect if the workstation is locked: http://www.codeproject.com/KB/vb/DetectWindowslockunlock.aspx Again, you could adapt that from C# to any language that can call the necessary APIs.

It sounds like the rest of what you want to know is in the screensaver state, mainly. Here's a Microsoft article that describes checking the screensaver state with a Win32 API call (using VB in the example, but you could do it in any language that lets you call that API): http://support.microsoft.com/kb/315725

If you define "idle" as the screensaver running then you can get "idleness" the same way. If you have some different definition of "idle" then you're on your own-- the OS won't help you with that.

Share:
6,062

Related videos on Youtube

0xdeadbeef
Author by

0xdeadbeef

Updated on September 17, 2022

Comments

  • 0xdeadbeef
    0xdeadbeef over 1 year

    I have a server running windows 2000 right now, will upgrade to 2003 pretty soon. Is there a way to check the user status and pc status?

    For example,

    • If the user is idle
    • If the PC is locked
    • How long the user has been logged in

    Doesn't matter if it does not work in windows 2000, though it'll be great if it does.

    Thanks for any help :)

    • Chris
      Chris almost 15 years
      These seem like odd things to monitor on a server. What is the problem you're trying to solve?
  • 0xdeadbeef
    0xdeadbeef almost 15 years
    I'm pretty new to windows servers, that explains a lot of things. Thanks!