[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 336
  • Last Modified:

Allow users to share database Windows 7

I have a VB.net program that uses an Access database and all is installed on a standalone PC.

1. I have created a deployment project which copies the database to:-

Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData).ToString & "\MyApplicationName"

2. I have modified the application manifest file to include:-

 <trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
    <security>
      <applicationRequestMinimum>
        <defaultAssemblyRequest permissionSetReference="Custom" />
        <PermissionSet class="System.Security.PermissionSet" version="1" ID="Custom" SameSite="site" Unrestricted="true" />
      </applicationRequestMinimum>
      <requestedPrivileges>
        <requestedExecutionLevel
          level="requireAdministrator"
          uiAccess="false"/>
      </requestedPrivileges>
    </security>
  </trustInfo>

When a user installs and selects to install for Everyone using Windows 7, all fine.

However, each time another users logs on to the PC Windows is copying the database from ProgramData to a 'virtual folder' for each user so they all see different data. How can I make the install so all users see the same data. I do not want to tell users they have to turn UAC off. I thought the whole idea of using special folders such as ProgramData was so that apps could share data without trying to use restricted folders. I modified the manifest as I was lead to believe the changes made the application 'UAC aware'.

I believe I may have to modify security settings on the folder I have created as it is not transferred to other users automatically.

I have added this routine to the install to update security on all folders created in the ProgramData folder but it still has not given Write/Modify/Full control to the folders for other users (non administrators or other admin users)

    Private Sub UpdateSecurity(ByVal FolderPath As String)

        Dim Level1DirSec As DirectorySecurity = Directory.GetAccessControl(FolderPath)

        Level1DirSec.AddAccessRule(New FileSystemAccessRule(New System.Security.Principal.SecurityIdentifier(System.Security.Principal.WellKnownSidType.BuiltinAdministratorsSid, Nothing), FileSystemRights.FullControl, InheritanceFlags.ContainerInherit + InheritanceFlags.ObjectInherit, PropagationFlags.None, AccessControlType.Allow))


    End Sub:

Also Just tried this as an attempt to spread security changes to all users and no luck

    Private Sub UpdateSecurity(ByVal FolderPath As String)


        Dim sid As New System.Security.Principal.SecurityIdentifier(System.Security.Principal.WellKnownSidType.WorldSid, Nothing)
        Dim acct As System.Security.Principal.NTAccount = TryCast(sid.Translate(GetType(System.Security.Principal.NTAccount)), System.Security.Principal.NTAccount)
        Dim strEveryoneAccount As String = acct.ToString()

        Dim Level1DirSec As DirectorySecurity = Directory.GetAccessControl(FolderPath)

        Level1DirSec.AddAccessRule(New System.Security.AccessControl.FileSystemAccessRule(strEveryoneAccount, System.Security.AccessControl.FileSystemRights.FullControl, System.Security.AccessControl.AccessControlType.Allow))

        Directory.SetAccessControl(FolderPath, Level1DirSec)


    End Sub
0
Trampas_c
Asked:
Trampas_c
  • 2
1 Solution
 
David Johnson, CD, MVPOwnerCommented:
programdata is great as a read-only area to update/write you need administrative rights because you are making a system-wide change. A few work-arounds are: use a local directory i.e. c:\database or change the access permissions for \programdata\myprogram\data to give everyone read/write/modify access.
0
 
Trampas_cAuthor Commented:
The correct location for common files has to be CommonApplicationData. As you can see from above I have tried to change the access rights.

I have found a link thatmay solve this but it is not written in VB
http://www.codeproject.com/Tips/61987/Allow-write-modify-access-to-CommonApplicationData

I am going to post a new question asking specifically how to do this in VB
0
 
Trampas_cAuthor Commented:
I need to ask a new question as the issue revolves around access rights to CommonApplicatonData
0

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now