How about if I query the reverse DNS to give me the PC name - is there any connection between the PC name and the user that is logged onto it?
Main Topics
Browse All TopicsIs there a way to determine the Active Directory user that is logged onto a given IP Address?
I need to do this from perl using an LDAP lookup.
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Unfortunately, AD doesn't hold this info.
The nearest you could get would be to interrogate each and every DC's security event logs and look for the last succesful logon attempt for the user, then parse the source workstation IP address from the data in that event log.
Or you could use WMI to connect to a machine by IP address and get the logged on user. A vbscript example i here: http://blogs.msdn.com/alej
You may be able to use this to figure out how to interrogate WMI with PERL. Unfortunately don't know much in the way of PERL so couldn't comment. May be worth adding the PERL zone to this question.
But with regards to using LDAP - this isn't possible as the information doesn't exist in AD.
Tony
Sorry Mike - must refresh!
stefanx - no, there is no dynamic data stored in AD that tells you what user is logged on where. Not in AD. DC's record events when users log on to machines, so you can query their event logs, but this wouldn't be LDAP, you would need to use WMI.
A more direct approach would be to interrogate the actual machine in question and fnd out the logged on user.
Scriptomatic can write Perl code if you do end up going down the WMI route :)
http://www.microsoft.com/d
If there's a need to track this kind of thing you may consider setting up a logon / logoff script to capture it, interrogating files created by that is far quicker and easier than WMI. There are quite a few variations on that, personally I use a minor variation of this one:
http://msmvps.com/blogs/kw
If it must be server-side and nothing on the client this article describes how events are logged in the Security log:
http://technet.microsoft.c
That can be painful if you have anything more than a couple of DCs.
Chris
As Chris stated, a good way would be to create a logon/off script to track this.
Another option to a text file might be to keep this info in AD, then you could query this data in your PERL script via LDAP.
For example, employeeID and employeeType are typically not used, and are not shown in ADUC. If this is the case for you, you could have a login script similar to the below. This writes a space-delimited string of the IP addresses of the machine the user is logged on to to 'employeeID'. Then in your PERL script you would use an LDAP filter similar to this:
(&(objectClass=user)(
(
By creating a similar logoff script which clears employeeID, you can track who is currently logged on to what machine just by performing this query.
For this you would also have to delegate 'SELF' the right to read/write the attribute in question, which can be done easily with the delegation of control wizard in ADUC.
Tony
We got Cisco works at work that have a utility where you type the username and his IP pops up or visa verca.
I have no clue what the cost is.
http://www.cisco.com/en/US
SG
Business Accounts
Answer for Membership
by: mkline71Posted on 2009-08-23 at 01:39:48ID: 25161817
Not that I know of; there is no IP address attribute that you can query using an LDAP query.
Maybe use a logon script to record the IP address and put it in a text file, but that wouldn't be used for an LDAP query either.
Thanks
Mike