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
{
}
}
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