none
Setting and Drag and Drop Permissions for System or Everyone for Specific Folders using Windows Registry RRS feed

  • Question

  • Hello,

    Cloud computing has mainstreamed worldwide, and users have been concerned whether which folders to drag and drop.

    My concern is to set my drag and drop permissions for System or Everyone for specific folders by using the Windows Registry library.  

    Should I use the User Access Control libraries as well? 

    Regards,

    JohnDBCTX


    jp

    Thursday, August 29, 2019 12:19 AM

Answers

  • Hi,

    You can use the following method to add  permissions to a folder.

      Private Shared Sub AddSecurityControll2Folder(ByVal dirPath As String)
            Dim dir As DirectoryInfo = New DirectoryInfo(dirPath)
            'get all access to this folder
            Dim dirSecurity As System.Security.AccessControl.DirectorySecurity = dir.GetAccessControl(AccessControlSections.All)
            Dim myinherits As InheritanceFlags = InheritanceFlags.ContainerInherit Or InheritanceFlags.ObjectInherit
            'add access  for the ereryone ,Full control permissions
            Dim everyoneFileSystemAccessRule As FileSystemAccessRule = New FileSystemAccessRule("Everyone", FileSystemRights.FullControl, myinherits, PropagationFlags.None, AccessControlType.Allow)
            'add access  for the user  ,Full control permissions
            Dim usersFileSystemAccessRule As FileSystemAccessRule = New FileSystemAccessRule("Users", FileSystemRights.FullControl, myinherits, PropagationFlags.None, AccessControlType.Allow)
            Dim isModified As Boolean = False
            dirSecurity.ModifyAccessRule(AccessControlModification.Add, everyoneFileSystemAccessRule, isModified)
            dirSecurity.ModifyAccessRule(AccessControlModification.Add, usersFileSystemAccessRule, isModified)
            dir.SetAccessControl(dirSecurity)
        End Sub

    Best Regards,

    Alex



    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Marked as answer by JohnDBCTX Wednesday, September 4, 2019 3:31 AM
    Thursday, August 29, 2019 2:09 AM

All replies

  • Hi,

    You can use the following method to add  permissions to a folder.

      Private Shared Sub AddSecurityControll2Folder(ByVal dirPath As String)
            Dim dir As DirectoryInfo = New DirectoryInfo(dirPath)
            'get all access to this folder
            Dim dirSecurity As System.Security.AccessControl.DirectorySecurity = dir.GetAccessControl(AccessControlSections.All)
            Dim myinherits As InheritanceFlags = InheritanceFlags.ContainerInherit Or InheritanceFlags.ObjectInherit
            'add access  for the ereryone ,Full control permissions
            Dim everyoneFileSystemAccessRule As FileSystemAccessRule = New FileSystemAccessRule("Everyone", FileSystemRights.FullControl, myinherits, PropagationFlags.None, AccessControlType.Allow)
            'add access  for the user  ,Full control permissions
            Dim usersFileSystemAccessRule As FileSystemAccessRule = New FileSystemAccessRule("Users", FileSystemRights.FullControl, myinherits, PropagationFlags.None, AccessControlType.Allow)
            Dim isModified As Boolean = False
            dirSecurity.ModifyAccessRule(AccessControlModification.Add, everyoneFileSystemAccessRule, isModified)
            dirSecurity.ModifyAccessRule(AccessControlModification.Add, usersFileSystemAccessRule, isModified)
            dir.SetAccessControl(dirSecurity)
        End Sub

    Best Regards,

    Alex



    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Marked as answer by JohnDBCTX Wednesday, September 4, 2019 3:31 AM
    Thursday, August 29, 2019 2:09 AM
  • Okay, that's a good start.

    Specifically, what does that code snippet does indicate?  Does it mean to grant and to deny access controls for users and for everyone as well?

    Now from there, which methods would enable users to drag and drop?

    Would it be returned as a Boolean flag type?

    Regards,

    JohnDBCTX


    jp


    imports System.Windows.Forms.DragEventHandler

    Private Drag_It as DragDrop private Shared Sub AddSecurityControl2Folder(ByVal dirPath as String) end sub


    • Edited by JohnDBCTX Thursday, August 29, 2019 3:13 AM Idea with code snippet
    Thursday, August 29, 2019 2:53 AM
  • Hi,

    see the FileSystemRights Enum

    Best Regards,

    Alex


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, August 29, 2019 7:29 AM