如何确定“开放模式”?共享文件在远程服务器上打开? [英] How can I determine the "Open Mode" of shared files open on a remote server?

查看:116
本文介绍了如何确定“开放模式”?共享文件在远程服务器上打开?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我在使用CAD的工程和设计小组工作。偶尔,我们会挂起文件锁,要求我们删除锁。由于安全限制,我们无法访问锁定文件所在的服务器。



我创建了一个连接到共享服务器的管理应用程序,并使用模拟,获取非管理员用户的所有打开文件的列表。它不依赖于openfiles.exe程序来执行此操作,它使用以下代码构建列表:



Hi,

I work in an Engineering and Design group that uses CAD. Occasionally, we get hanging file locks that require us to remove the lock. Due to security constraints, we do not have access to the server on which the locked file resides.

I created an admin application that connects to a shared server and, using impersonation, gets the list of all open files for non-admin users. It does not rely on the openfiles.exe program to do so, it builds the list using the following code:

DirectoryEntry sessQuery = new DirectoryEntry("WinNT://" + serverName + "." + sWhere + ".apci.com/LanmanServer",
    sWhere + "\\" + sWho,
    sAuth,
    AuthenticationTypes.ServerBind);
IADsFileServiceOperations fso = sessQuery.NativeObject as IADsFileServiceOperations;
IADsCollection resources = fso.Resources();
foreach (IADsResource res in resources)
{
    try
    {
        dT.Rows.Add(res.Name, res.Path, res.User);
    }
    catch
    {
        // Do Nothing - just skip
    }
}





这给了我一个数据表(在代码片段上方定义),其中包含名称(实际上是文件ID),完整路径以及打开文件的用户。



使用共享文件时 - >服务器管理控制台上的打开文件,有一个名为开放模式的列,用于标识文件是打开只读还是写入读取。这对我们的管理团队来说是有用的信息,用于确定文件是被引用还是主动编辑。



问题是我无法弄清楚这是哪里的信息来自。我没有在IADsResource或相关接口(来自IADsFileServiceOperations)中找到可能提供该信息的任何内容。



我在哪里可以获取当前打开文件的信息?



在此先感谢,

加里



This gives me a data table (defined above the code snippet) that contains the name (which is, in reality, the file ID), full path, and user that has the file open.

When using Shared Files -> Open Files on the server management console, there is a column called Open Mode that identifies whether the file is open read-only or write-read. This is useful information for our admin team, used to determine if the file is being referenced or actively edited.

The problem is that I can't figure out where this information is coming from. I haven't found anything in the IADsResource or related interfaces (from IADsFileServiceOperations) that might provide that information.

Where can I get that information for the currently open files?

Thanks in advance,
Gary

推荐答案

你可以使用LockCount资源的属性,即res.LockCount



将res.lockCount添加到您的表中。如果LockCount> 0然后它只是readonly文件。



尝试

{

dT.Rows.Add(res。姓名,res.Path,res.User,res.LockCount);

}

catch
you can use LockCount property of resources i.e. res.LockCount

add res.lockCount to your table. if the LockCount > 0 then then it is readonly files.

try
{
dT.Rows.Add(res.Name, res.Path, res.User ,res.LockCount);
}
catch


这篇关于如何确定“开放模式”?共享文件在远程服务器上打开?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆