Re: Return computer name
- From: "Richard Mueller [MVP]" <rlmueller-nospam@xxxxxxxxxxxxxxxxxxxx>
- Date: Tue, 18 Aug 2009 15:02:34 -0500
A third party tool that might help is LimitLogin:
http://technet.microsoft.com/en-us/magazine/2005.05.utilityspotlight.aspx
The purpose is to limit logins, but to do this it must keep track of users
(and the computers they are logged into). The link explains that most
similar solutions maintain a separate SQL database, but this one creates an
application directory partition in AD for the purpose. The GUI provided may
enable you get the information you want. Or, you probably can use ADO to
query the partition for the user name or the computer name. If you go this
route, this link on using ADO to query AD in VBScript programs should help:
http://www.rlmueller.net/ADOSearchTips.htm
The base of your query would be the new application partition. You could use
ADSI Edit to browse the new partition and determine the objects and
attributes available.
--
Richard Mueller
MVP Directory Services
Hilltop Lab - http://www.rlmueller.net
--
"James" <dontemailme@xxxxxxxxxxxxxxx> wrote in message
news:uVbatiCIKHA.1380@xxxxxxxxxxxxxxxxxxxxxxx
Thanks again Richard
"Richard Mueller [MVP]" <rlmueller-nospam@xxxxxxxxxxxxxxxxxxxx> wrote in
message news:OtS3B8BIKHA.3708@xxxxxxxxxxxxxxxxxxxxxxx
"James" <dontemailme@xxxxxxxxxxxxxxx> wrote in message
news:OxOFyQBIKHA.1376@xxxxxxxxxxxxxxxxxxxxxxx
I have found the following code example...
It is along the lines of what I am looking for. All I have to do is
input the user name and it will return some info from AD. I just need
it to return the name or IP address of the computer the user is
currently using. Can that be done?
Option Explicit
Dim strComputer, strUsername, objWMI, colUsers, objUser
strComputer = "."
Set objWMI = GetObject("winmgmts:\\" & strComputer &
"\root\directory\LDAP")
strUsername = InputBox("Please type the user name")
Set colUsers = objWMI.ExecQuery("SELECT * FROM ds_user where
ds_sAMAccountName = '" & strUsername & "'")
If colUsers.Count > 0 Then
For Each objUser in colUsers
WScript.Echo "First Name: " & objUser.ds_givenName
WScript.Echo "Last Name: " & objUser.ds_sn
Next
Else
WScript.Echo "No users found!"
End If
James
"James" <dontemailme@xxxxxxxxxxxxxxx> wrote in message
news:Oxz19tAIKHA.4436@xxxxxxxxxxxxxxxxxxxxxxx
Is is possible to return the name of the computer an AD user is using
if you only know their user name? If so, any examples or links to
example you could provide would be great. I am looking to use pure
vbs, no HTA, no HTML...if possible.
regards,
James
Active Directory does not keep track of which user is logged into which
computer. In fact, AD doesn't even keep track if the user is still logged
on at all.
The code snippet you included is new to me, but it appears to query an
LDAP database on the machine, in which case it must be run on a Domain
Controller (or connect to it remotely by assigning the NetBIOS name of
the DC to the variable strComputer). Given the value of the
sAMAccountName attribute (the "pre-Windows 2000 logon name"), it
retrieves other attributes of the user object. However, there are no
attributes of user objects indicating which PC the user is currently
logged into. The main purpose of AD is to store relatively stable
information that changes infrequently. Network traffic would be increased
significantly if AD had to replicate new information to all DC's
everytime someone logged on and off.
I believe there are third party tools that attempt to give you the
information you ask for. Someone else may respond with more information
that.
Otherwise, one method I've used in the past, but which is unreliable,
uses the LanmanServer service on a computer to enumerate sessions:
============
Option Explicit
Dim objDC, objSession, strComputer
strComputer = "MyServer"
Set objDC = GetObject("WinNT://" & strComputer & "/LanmanServer")
For Each objSession In objDC.Sessions
Wscript.Echo objSession.Name
Wscript.Echo objSession.User
Wscript.Echo objSession.Computer
Next
=======
This only enumerates active sessions on the one computer. If the user is
not currently doing something on the machine, the session disappears.
Plus, you would need to run this on every DC and member server where a
user might be using network resources.
Otherwise, I have used logon and logoff scripts to keep track of which
user uses which computer. The scripts log the user name, date/time, and
computer name to a shared log file. This file can be copied and opened by
a spread*** program where you can filter/sort by user, computer, date,
etc. In principal you can tell which computer a given user was using when
you copied the log file. I have VBScript examples at this link:
http://www.rlmueller.net/Logon5.htm
--
Richard Mueller
MVP Directory Services
Hilltop Lab - http://www.rlmueller.net
--
.
- References:
- Return computer name
- From: James
- Re: Return computer name
- From: James
- Re: Return computer name
- From: Richard Mueller [MVP]
- Re: Return computer name
- From: James
- Return computer name
- Prev by Date: Re: How to set Paper size in vbs
- Next by Date: Re: Finding Current User Network Drives in the Registry
- Previous by thread: Re: Return computer name
- Next by thread: Appending to an XML file
- Index(es):