Results 1 to 10 of 10

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

  1. #1
    aljeff is offline VB.NET Forum Newbie
    .NET Framework
    .NET 3.5
    Join Date
    Feb 2012
    Posts
    13
    Reputation
    18

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

    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 by aljeff; 02-20-2012 at 9:47 AM.

  2. #2
    JohnH's Avatar
    JohnH is online now VB.NET Forum Moderator
    .NET Framework
    .NET 4.0
    Join Date
    Dec 2005
    Location
    Norway
    Posts
    14,183
    Reputation
    2368
    The classes you should look into is RegistryKey, FileInfo and DirectoryInfo. You'll find they all have a GetAccessControl method.

  3. #3
    aljeff is offline VB.NET Forum Newbie
    .NET Framework
    .NET 3.5
    Join Date
    Feb 2012
    Posts
    13
    Reputation
    18

    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.Acces sControlSections.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

  4. #4
    JohnH's Avatar
    JohnH is online now VB.NET Forum Moderator
    .NET Framework
    .NET 4.0
    Join Date
    Dec 2005
    Location
    Norway
    Posts
    14,183
    Reputation
    2368
    Have you research RegistryKey class like I said? Once you have opened the key using GetAccessControl method is the same.

  5. #5
    aljeff is offline VB.NET Forum Newbie
    .NET Framework
    .NET 3.5
    Join Date
    Feb 2012
    Posts
    13
    Reputation
    18
    Quote Originally Posted by JohnH View Post
    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

  6. #6
    JohnH's Avatar
    JohnH is online now VB.NET Forum Moderator
    .NET Framework
    .NET 4.0
    Join Date
    Dec 2005
    Location
    Norway
    Posts
    14,183
    Reputation
    2368
    So what exactly is the problem?

  7. #7
    aljeff is offline VB.NET Forum Newbie
    .NET Framework
    .NET 3.5
    Join Date
    Feb 2012
    Posts
    13
    Reputation
    18
    Quote Originally Posted by JohnH View Post
    So what exactly is the problem?
    I cannot write the rigth code for this.
    I'm just new to VB.Net.

  8. #8
    aljeff is offline VB.NET Forum Newbie
    .NET Framework
    .NET 3.5
    Join Date
    Feb 2012
    Posts
    13
    Reputation
    18
    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.
    Attached Images Attached Images

  9. #9
    JohnH's Avatar
    JohnH is online now VB.NET Forum Moderator
    .NET Framework
    .NET 4.0
    Join Date
    Dec 2005
    Location
    Norway
    Posts
    14,183
    Reputation
    2368
    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

  10. #10
    aljeff is offline VB.NET Forum Newbie
    .NET Framework
    .NET 3.5
    Join Date
    Feb 2012
    Posts
    13
    Reputation
    18
    Quote Originally Posted by JohnH View Post
    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.V alue & " - " & FullPermissions.ToString)
    Example output of this line: BUILTIN\User - FullControl

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

Bookmarks

Posting Permissions

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