From: Mike on 18 Nov 2009 08:34 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
From: Andrew Morton on 18 Nov 2009 09:13 Mike wrote: > 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
From: Mike on 18 Nov 2009 12:00 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 "Andrew Morton" wrote: > Mike wrote: > > 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 > > > . >
From: Andrew Morton on 18 Nov 2009 12:21 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) -- Andrew
From: Andrew Morton on 18 Nov 2009 12:24 Oops! Return owner.Properties("Name").Value.ToString() -- Andrew
|
Next
|
Last
Pages: 1 2 Prev: How to IBinarySerialize a List(Of T) Next: Validate Password against Domain Policy |