Determining who is accessing a file on a shared folder in Windows 2008 R2 server / Windows 7

江枫思渺然 提交于 2019-12-23 03:51:50

问题


I need to find a way to determine what files on a shared folder are being accessed, and by whom. Commands like "Net Files" and "Net Session" can give this information, as well as PSFile.exe in SysInternals, but I cannot figure out how to do this programmatically. I have found a way to determine who is accessing a share via WMI, but it does not show what file is being accessed. Does anyone know how to do this in C / C++ / C#? Any and all help will be greatly appreciated.


回答1:


NetFileEnum level 3 seems to be what you're looking for.




回答2:


You can use ADSI (Active Directory Service Interfaces) , some time ago I wrote an article about this topic Using Delphi and ADSI to enumerate local and remote shared resources the samples are written in delphi but you can use this article as a guide to ADSI.

To List the opened resources like folders and files you must use the IADsFileServiceOperations interface and the Resources function which return a collection of the open resources for the service.



来源:https://stackoverflow.com/questions/7854951/determining-who-is-accessing-a-file-on-a-shared-folder-in-windows-2008-r2-server

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!