Reading NT File & Folder Permissions
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: Reading NT File & Folder Permissions

  1. #1
    Join Date
    Feb 2011
    Posts
    1

    Reading NT File & Folder Permissions

    I would like to read the NT Security (Read, Write, List, Inherited, blah blah blah) permissions from a file. I already have some code, and can get the names and SIDs, but canít seem to figure out the actual access bits. I have found how to SET them, but not read.

    Here is what I have so far:
    Code:
    Imports System
    Imports System.IO
    Imports System.Security
    Imports System.Security.AccessControl
    Imports System.Security.Permissions
    Imports System.Security.Principal
    
    Module modPermissionFunctions
    Public Structure ACLInfo
     Dim objARCUsers As AuthorizationRuleCollection
     Dim objARCSIDs As AuthorizationRuleCollection
     Dim objARCPerms As AuthorizationRuleCollection
     Dim strOwner As String
     Dim strOwnerSID As String
     Dim bitError As Boolean
     Dim strErrorMessage As String
     End Structure
     
     
     Sub GetFSObjectSecurity(ByRef strFileName As String, ByRef objRules As ACLInfo)
     Try
     Dim objFileInfo As New FileInfo(strFileName)
     Dim objAC As FileSystemSecurity = objFileInfo.GetAccessControl()
     With objRules
     .strOwner = objAC.GetOwner(GetType(System.Security.Principal.NTAccount)).Value
     .strOwnerSID = objAC.GetOwner(GetType(System.Security.Principal.SecurityIdentifier)).Value
     .objARCUsers = objAC.GetAccessRules(True, True, GetType(System.Security.Principal.NTAccount))
     .objARCSIDs = objAC.GetAccessRules(True, True, GetType(System.Security.Principal.SecurityIdentifier))
     .objARCPerms = >>Here is where I need help<<
     End With
     
    objRules.bitError = False
     Catch ex As Exception
     objRules.bitError = True
     objRules.strErrorMessage = ex.Message
     End Try
     End Sub
     End Module

  2. #2
    Join Date
    Jan 2006
    Location
    Chicago, IL
    Posts
    14,951

    Re: Reading NT File & Folder Permissions

    What are you trying to do, in the end? Hard to tell by your description
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center