How can I determine who is logged on to a remote Windows XP computer from Linux? I do not have administrator access on the domain or on the remote computer.
I can do it from a separate Windows computer using PsLoggedOn -L \\computer
from PsTools
I've tried using nmblookup -A remotecomputer
, but I only see entries for the
computer and the domain, not a <03>
entry for the user.
I've also tried running PsLoggedOn under wine; I get an error:
Connecting to Registry of \\computer.company.com... fixme:reg:RegConnectRegistryW Connect to L"computer.company.com" is not supported.
I started looking into winexe, but it looks like I would need administrative rights on the remote computer to get it working.
Best Answer
I found how to do this using Samba on the Linux computer.
I installed and configured Kerberos and Samba to access the domain. I modified
/etc/samba/smb.conf
,/etc/krb5.conf
, and/etc/hosts
. I then used somenet
commands from a script (net
is a command-line interface to Samba):giving a list of the security identifiers for the users that are currently loaded in the registry:
I then run the
net ads sid
command to lookup active directory entries based on the user SID. This might only work for domain users; I'm not sure if it works for users logged on using a local account. It seems that if there are multiple SIDs, the only one that works is the one that has a corresponding "_Classes" entry.This gives some errors, but still results in printing the user's entire Active Directory information. It is fairly slow, possibly due to the errors, so I might cache the SID-to-username mapping.
The mailNickname field contains the user name (at least for the users I have tested so far).