需求:要能夠知道Windows2003文件服務器上的某個文件是被哪個域用戶在哪個計算機上打開
問題:
已經解決:可以用Openfiles命令或PsFile程序找到打開文件的用戶。
未解決:不知道如何用命令找到某個用戶在哪個計算機上登錄。
尋求幫助:有什麼命令或工具可以察看域用戶在哪個計算機上登錄?
問題:
已經解決:可以用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=")
' 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 = 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
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)
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
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
Loop
of.close
MsgBox "Done! Cheers!"
MsgBox "Done! Cheers!"
希望我的回答對您有所幫助,如果您還有什麼問題,請您再和我們聯繫。
Tom Zhang 張一平
Tom Zhang – MSFT