Question How to determine permission/s given to a file, folder, and registries?

aljeff

Member
Joined
Feb 20, 2012
Messages
13
Programming Experience
Beginner
I need to create a program that will determine permission/s given to a files, folders, and registries.

Example:

If the user will input the ff:
Folder: C:\Program Files\Adobe
File: C:\Program Files\Adobe\ReadMe.htm
Registry: HKLM\SOFTWARE\Microsoft\Adobe

The output will be for the 4 groups.

C:\Program Files\Adobe:
System - Full Control
Administrators - Full Control
Users - Modify
Power Users - Modify

C:\Program Files\Adobe\ReadMe.htm:
System - Full Control
Administrators - Full Control
Users - Modify
Power Users - Full Control

HKLM\SOFTWARE\Microsoft\Adobe:
System - Full Control
Administrators - Full Control
Users - Special
Power Users - Special


In case with the folders and registries it should determine if the permission was cascaded down to files/subfolders and registry keys.

Legends:
Full Control
includes (Allows Full Control, Modify, Read&execute, List folder contents, Read, Write)
Modify includes (Allows Modify, Read&execute, List folder contents, Read, Write)
Special (for registries only) excludes (Nofity)

I don't know what functions/components to use or do you have code snippet there as for reference?
This program will run on Windows 7 - 32 Bit(x86) with .Net 3.5

Should you have any clarifications and suggestions please let me know

Regards,
Jeff
 
Last edited:
The classes you should look into is RegistryKey, FileInfo and DirectoryInfo. You'll find they all have a GetAccessControl method.
 
Query the Registry Permissions set into a Key

Hello, Everyone!

I'm new in VB.Net Programming.

I have this code for File/Folders to get the query all permissions given in a File and Folder.

[XCODE]

ImportsSystem.Security.AccessControl

Dim File As New IO.FileInfo("C:\example_file.txt")
For Each Rule As Security.AccessControl.FileSystemAccessRule In File.GetAccessControl(Security.AccessControl.AccessControlSections.Access).GetAccessRules(True, True, GetType(Security.Principal.NTAccount))
lstSecurity.Items.Add(Rule.IdentityReference.Value & " - " & FullPermissions.ToString)
Next

[/XCODE]

Doing it for directories is exactly the same apart to use IO.DirectoryInfo instead of FileInfo etc.

2.PNG
This will be the output for Directory and File.
(Never mind the duplicate users, codes needs to recheck again)

Also this will be output for Registry but I don't know how.

But now I don't know how to convert it to query all permission given to a registrykey.
Permission should put on a listbox.

Could anyone do a code snippet for me to query the list of permission given to a registry key and put it on a list box?

How to deal with the Registry path.

Regards,
Jeff
 
Have you research RegistryKey class like I said? Once you have opened the key using GetAccessControl method is the same.
 
Have you research RegistryKey class like I said? Once you have opened the key using GetAccessControl method is the same.

Hi, John.

Yes, I already research the RegistryKey Class.
But I can't still query the permissions for the registries. :(

Regards,
Jeff
 
So what exactly is the problem?
 
Hello, JohnH.

I'm in the mid of creating a program that will get the security permissions of a certain folder/s but some properties of the security permissions of a certain folder I can't query or get the values. I'm using VB.NET 2010. I tried GetAccessControl method but no luck.

This what I want to get in every permission

Apply to:
This folder and subfolders
This folder, subfolders and files
Subfolder and files

etc...

I attached the picture so you could see what I'm saying.I'm just noob in programming:( so please do bear with me.

Thank you.
 

Attachments

  • Permission.PNG
    Permission.PNG
    64.1 KB · Views: 37
check the InheritanceFlags and PropagationFlags properties: FileSystemAccessRule Properties (System.Security.AccessControl)
In for example this article you can find figures that show the effect of these flags: Manage Access to Windows Objects with ACLs and the .NET Framework


Hello, JohnH.

Hmmm... seems its hard for me to understand.

I attached a notepad containing some of the codes. I can get the InheritanceFlags and PropagationFlags properties but I dont know how to use or code it on my program.
Kindly help me on this. Just teach mo where should I put the codes and what will be the correct code for this.

I should able to get the following.

BUILTIN\User - FullControl - This folder and subfolders
BUILTIN\Power User - FullControl -This folder, subfolders and files
BUILTIN\Administrator - FullControl -Subfolder and files

This is the line when I add the queried permission - lstFileSecurity.Items.Add(Rule.IdentityReference.Value & " - " & FullPermissions.ToString)
Example output of this line: BUILTIN\User - FullControl

NOTE:
btnSubmit - button
lstFileSecurity - Listbox
lstFolderSecurity - listbox
txtFolderPath.Text - textbox
txtFilePath.Text - textbox
 

Attachments

  • permission.txt
    3.9 KB · Views: 35
Back
Top