需求:要能够知道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