我在本地网络中有文件/文件夹的路径,我需要查看其用户主机名或IP。 我使用了现有的代码,例如:
FILENAME = r'Y:\\Projects\\Username\\test_json.js'
sd = win32security.GetFileSecurity (FILENAME, win32security.OWNER_SECURITY_INFORMATION)
owner_sid = sd.GetSecurityDescriptorOwner ()
name, domain, typ = win32security.LookupAccountSid ('server', owner_sid)
最后我得到一个PC登录名 但是可以获取文件夹\文件用户的网络名称或IP吗?
答案 0 :(得分:0)
您可以使用SELECT
ifnull(COUNT(speech.contact),0)
FROM
speech
WHERE
speech.contact = staff.staffid
GROUP BY speech.contact) AS 'Contact Count'
从网络驱动器获取UNC路径。并包含主机名。
win32wnet.WNetGetUniversalName
UNC路径类似于:
import win32wnet
import sys
print(win32wnet.WNetGetUniversalName(FILENAME, 1))
您可以通过以下方式获取IP地址
\\hostname\sharename\filepath