Hi
I have an application that is writing a comma separated values file. How would I go about altering the permissions of that file from .NET - for example to give read-only permissions to a particular active directory group?
Thanks
Duncan
Printable View
Hi
I have an application that is writing a comma separated values file. How would I go about altering the permissions of that file from .NET - for example to give read-only permissions to a particular active directory group?
Thanks
Duncan
Are you looking to do this with the readonly attribute, or actually with the ACL?
With the ACL.
What I'm hoping for is:
Europe\FundAccountants read-only
Europe\TransferAgency read-write
Public - no access
Have you seen this link?
http://dhcollier.com/node/3
I'm not so sure with active directory as I haven't ever had to program against it since my software is generally of the single user commercial client type. However I did have a need to set ACL for a given folder and I used this code. I *think* it could be adapted to work with an AD group, just the same as it works with a built in users group. If not hopefully it will get you in the right direction.
Code:Imports System.Security.AccessControl
Imports System.IO
Private Function SetUserAccess(ByVal FolderPath As String) As Boolean
Try
Dim myDirectorySecurity As System.Security.AccessControl.DirectorySecurity = System.IO.Directory.GetAccessControl(FolderPath)
Dim UsersGroupIdentifier As New Security.Principal.SecurityIdentifier(Security.Principal.WellKnownSidType.BuiltinUsersSid, Nothing)
Dim myAccessRule As New FileSystemAccessRule(UsersGroupIdentifier, _
FileSystemRights.FullControl, _
InheritanceFlags.ObjectInherit Or _
InheritanceFlags.ContainerInherit, _
PropagationFlags.InheritOnly, _
AccessControlType.Allow)
myDirectorySecurity.AddAccessRule(myAccessRule)
Directory.SetAccessControl(FolderPath, myDirectorySecurity)
Return True
Catch ex As Exception
'LOG EXCEPTION HERE
Return False
End Try
End Function