Looking For Ideas/Help with Security Application

ss7thirty

Well-known member
Joined
Jun 14, 2005
Messages
455
Location
New Jersey, US
Programming Experience
5-10
I am currently looking for a better way to manage the permissions of file access over a network. I currently have some code that simply changes the file permission of one user. I am looking for a good way to modify the permissions. For example, when a certain job is delivered users will no longer need write access in that folder so all users that are not administrators should be shut off. Here is what I have scribbled down so far. This simply changes that permissions of one user to one file. If there are any ideas of how to do this on a much larger scale or with a property grid or something like that. Maybe where I can type in a folder name and it will display all of the permissions, and let me add/delete users and modify their permissions similar to the interface that windows provides but I want to be able to make it a bit faster and able to update itself based on things that happen throughout the system. Anyway, here is the code that changes the permission of one file for one user:


Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.TextBox1.Text = "e:\dave.txt"
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim fi As System.IO.FileInfo
If System.IO.File.Exists(TextBox1.Text) Then
fi = New System.IO.FileInfo(TextBox1.Text)
End If
Dim fs As FileSecurity = fi.GetAccessControl


Dim ir As IdentityReference = fs.GetOwner(GetType(NTAccount))
Me.TextBox2.AppendText("Owner: " & ir.Value & vbCrLf)
ir = fs.GetGroup(
GetType(NTAccount))
Me.TextBox2.AppendText("Group: " & ir.Value & vbCrLf)
Dim sdBytes() As Byte = fs.GetSecurityDescriptorBinaryForm()
Dim csd As New CommonSecurityDescriptor(False, False, sdBytes, 0)

For Each MyAce As CommonAce In csd.DiscretionaryAcl
' Me.TextBox2.AppendText(String.Format("User {0} .. Rights {1} .. " & vbCrLf, MyAce.AceType.ToString, MyAce.SecurityIdentifier.Translate(GetType(NTAccount))))
' Console.WriteLine(MyAce.AccessMask.ToString)
Next

For Each Far As FileSystemAccessRule In fs.GetAccessRules(True, True, GetType(NTAccount))
Me.TextBox2.AppendText(Far.AccessControlType.ToString & " " & _
Far.IdentityReference.ToString &
" " & _
Far.FileSystemRights.ToString & vbCrLf)
Next
Dim fsar As New FileSystemAccessRule(New NTAccount("EGYPT", "Steve"), FileSystemRights.FullControl, AccessControlType.Allow)
fs.AddAccessRule(fsar)
fi.SetAccessControl(fs)
End Sub
 
Back
Top