如何用命令查看域用户登陆的计算机
2010-10-28 16:03
337 查看
http://social.microsoft.com/Forums/es-ES/windowsserversystemzhchs/thread/981ace17-20f0-423d-bc05-d95db2f13bbc
需求:要能够知道Windows2003文件服务器上的某个文件是被哪个域用户在哪个计算机上打开
问题:
已经解决:可以用Openfiles命令或PsFile程序找到打开文件的用户。
未解决:不知道如何用命令找到某个用户在哪个计算机上登录。
寻求帮助:有什么命令或工具可以察看域用户在哪个计算机上登录?
答:
您可以在域控制器上新建一个VBS文件,并将以下内容拷贝进去,然后运行该脚本文件,查看那些域用户登录在域中的那台客户端上。
' Script for getting current logged user name on Domain
' Author : mwpq
' www.sharecenter.net
strDomainName = InputBox ("Please enter the internal Domain Name:","Script for getting current logged username","yourdomain.local")
arrDomLevels = Split(strDomainName, ".")
strADsPath = "dc=" & Join(arrDomLevels, ",dc=")
Const ADS_SCOPE_SUBTREE = 2
Set objConnection = CreateObject("ADODB.Connection")
Set objCommand = CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"'
Set objCOmmand.ActiveConnection = objConnection
objCommand.CommandText = _
"Select Name, Location from 'LDAP://"&strADsPath&"' " _
& "Where objectClass='computer'"
objCommand.Properties("Page Size") = 1000
objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE
Set objRecordSet = objCommand.Execute
objRecordSet.MoveFirst
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set of = oFSO.CreateTextFile("LoggedUser.txt", True, True)
Do Until objRecordSet.EOF
On Error Resume Next
sPC = objRecordSet.Fields("Name").Value
of.writeline " "
of.writeline "Machine Name: "&sPC
Set objWMILocator = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & sPC & "\root\cimv2")
If Err = 0 Then
Set col = objWMILocator.ExecQuery _
("Select * from win32_computersystem")
For Each item In col
of.writeline "Logged User: "&item.username
Next
Set col = Nothing
Else
of.writeline "!!! Cant connect to "&sPC&" !!!"
End If
objRecordSet.MoveNext
Loop
of.close
MsgBox "Done! Cheers!"
希望我的回答对您有所帮助,如果您还有什么问题,请您再和我们联系。
Tom Zhang 张一平
Tom Zhang – MSFT
需求:要能够知道Windows2003文件服务器上的某个文件是被哪个域用户在哪个计算机上打开
问题:
已经解决:可以用Openfiles命令或PsFile程序找到打开文件的用户。
未解决:不知道如何用命令找到某个用户在哪个计算机上登录。
寻求帮助:有什么命令或工具可以察看域用户在哪个计算机上登录?
答:
您可以在域控制器上新建一个VBS文件,并将以下内容拷贝进去,然后运行该脚本文件,查看那些域用户登录在域中的那台客户端上。
' Script for getting current logged user name on Domain
' Author : mwpq
' www.sharecenter.net
strDomainName = InputBox ("Please enter the internal Domain Name:","Script for getting current logged username","yourdomain.local")
arrDomLevels = Split(strDomainName, ".")
strADsPath = "dc=" & Join(arrDomLevels, ",dc=")
Const ADS_SCOPE_SUBTREE = 2
Set objConnection = CreateObject("ADODB.Connection")
Set objCommand = CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"'
Set objCOmmand.ActiveConnection = objConnection
objCommand.CommandText = _
"Select Name, Location from 'LDAP://"&strADsPath&"' " _
& "Where objectClass='computer'"
objCommand.Properties("Page Size") = 1000
objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE
Set objRecordSet = objCommand.Execute
objRecordSet.MoveFirst
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set of = oFSO.CreateTextFile("LoggedUser.txt", True, True)
Do Until objRecordSet.EOF
On Error Resume Next
sPC = objRecordSet.Fields("Name").Value
of.writeline " "
of.writeline "Machine Name: "&sPC
Set objWMILocator = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & sPC & "\root\cimv2")
If Err = 0 Then
Set col = objWMILocator.ExecQuery _
("Select * from win32_computersystem")
For Each item In col
of.writeline "Logged User: "&item.username
Next
Set col = Nothing
Else
of.writeline "!!! Cant connect to "&sPC&" !!!"
End If
objRecordSet.MoveNext
Loop
of.close
MsgBox "Done! Cheers!"
希望我的回答对您有所帮助,如果您还有什么问题,请您再和我们联系。
Tom Zhang 张一平
Tom Zhang – MSFT
相关文章推荐
- 如何使用命令查看mysql的当前登陆用户
- Linux如何查看登陆用户信息
- 用PLSQL操作数据库时用命令查看当前登陆用户的所有表
- Linux(17)查看用户登陆历史的几个命令
- Linux下查看用户登陆后的操作记录及history命令显示时间
- 如何查看域用户登陆域的时间?
- linux id命令参数及用法详解(linux查看当前登陆用户uid,gid)
- [fw]linux 下如何查看和踢除正在登陆的其它用户
- 如何查看用户当前shell和修改用户登陆时的默认shell
- Linux下查看用户登陆后的操作记录及history命令显示时间
- 如何查看用户当前shell和修改用户登陆时的默认shell
- linux id命令参数及用法详解(linux查看当前登陆用户uid,gid)
- 查看linux下登陆用户的行为信息―w和who命令详解
- Exchange 2007如何通过命令查看所有用户邮箱大小
- Linux下查看用户登陆后的操作记录及history命令显示时间
- Linux下查看用户登陆后的操作记录及history命令显示时间
- 如何解决网上邻居出现“登陆失败:未授予用户在此计算机上的请求登陆类型”的问题
- Linux查看用户登陆历史记录(last命令的使用)
- 用命令查看整个AD域用户目前正在登录的计算机名
- linux 管理小命令8—— 用户登陆查看