Filesystemwatcher file owner and filename length issue

  • Thread starter Thread starter Mike
  • Start date Start date
M

Mike

I have two questions my code question is in relation to a filename question
the other is about my proposed workaround

We have an app that sweeps directories this app fails when filenames are
over 92 characters long. We have tried to make the users not use filenames
that long but ... that doesn't work. We have created macros in Outlook to
keep users from saving files that long but that only works in Outlook.

Question 1 -- What options are there for enforcing "rules" regarding
filenames on a filserver? Windows 2003

Question 2 -- The reason the post is in this group. My idea is to get a
filesystemwatcher going to help me "police" the folders where the files are
being dropped. I have a file systemwatcher to notify me when a filename is
greater than 92 characters. How do I tell who put the file there? I would
like to notify them immediately! I have googled and can't get the file owner
portion of the code ..

Thanks for reading
 
Mike said:
Question 2 -- The reason the post is in this group. My idea is to
get a filesystemwatcher going to help me "police" the folders where
the files are being dropped. I have a file systemwatcher to notify
me when a filename is greater than 92 characters. How do I tell who
put the file there? I would like to notify them immediately! I have
googled and can't get the file owner portion of the code ..

I think you want to look at FileSecurity.GetOwner

Andrew
 
I have been trying this, from a code example and I am getting build erros

Imports System.Security.AccessControl
Imports System.Security.Principal


Public Function GetOwner(ByVal targetType As Type) As IdentityReference
Dim instance As ObjectSecurity
'Dim targetType As Type
Dim returnValue As IdentityReference

returnValue = instance.GetOwner(targetType)


Return GetOwner

End Function
 
I'm about to go home, so I don't have time to look at it, but in the
mean-time:

Private Function getOwner(ByVal path As String) As String
' It's a pain trying to get an apostrophe into a
Win32_LogicalFileSecuritySetting.Path
If path.IndexOf("'") > -1 Then
Return "Apostrophe found"
End If

mgmt.Path = New
System.Management.ManagementPath("Win32_LogicalFileSecuritySetting.Path='" &
path & "'")
Dim secDesc As ManagementBaseObject =
mgmt.InvokeMethod("GetSecurityDescriptor", Nothing, Nothing)
Dim descriptor As ManagementBaseObject =
CType(secDesc.Properties("Descriptor").Value, ManagementBaseObject)
Dim owner As ManagementBaseObject =
CType(descriptor.Properties("Owner").Value, ManagementBaseObject)
Return owner
End Function

(watch out for line-wrap)
 
Back
Top