Mel Weaver said:
Willy,
I can get a list of users or computer in the domain, using
DirectoryEntry, but I can't find a way to find what computers/users are
currently logged into the domain.
Mel
Mel,
Oh, sorry, I did mis-read your question.
Finding out precisely who's actually logged on into a domain is difficult
(if not impossible). There is no "central authority" that keeps track of
this.
Each logon server (DC) in a domain keeps track of the established logon
sessions (local and domain) , so when you have multiple domain controllers
(you should have) you will have to query all DC's in the domain to know the
users actually logged-on.
W2K3's WMI classes Win32_LogonSession and Win32_LoggedOnUser can be used to
enumerate the Domain Login's is through System.Management (WMI wrappers).
On W2K DC's you will have to PInvoke the LsaEnumerateLogonSessions and
LsaGetLogonSessionData security API's. Note that you can't do this from a
client, so you will have to provide the session info through a windows
service or (preferably) through a WMI instance provider interface
implemented using .NET.
Willy.