Solved

Allow users to share database Windows 7

Posted on 2013-06-27
3
320 Views
Last Modified: 2013-07-03
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
Comment
Question by:Trampas_c
  • 2
3 Comments
 
LVL 79

Expert Comment

by:David Johnson, CD, MVP
ID: 39282866
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
 

Accepted Solution

by:
Trampas_c earned 0 total points
ID: 39283900
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
 

Author Closing Comment

by:Trampas_c
ID: 39295971
I need to ask a new question as the issue revolves around access rights to CommonApplicatonData
0

Featured Post

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Possible fixes for Windows 7 and Windows Server 2008 updating problem. Solutions mentioned are from Microsoft themselves. I started a case with them from our Microsoft Silver Partner option to open a case and get direct support from Microsoft. If s…
While working, an annoying popup showing below will come and we cannot cancel or close it form the screen. The error message will come again and again.
This Micro Tutorial will teach you how to the overview of Microsoft Security Essentials. This is a free anti-virus software that guards your PC against viruses, spyware, worms, and other malicious software. This will be demonstrated using Windows…
The viewer will learn how to successfully download and install the SARDU utility on Windows 7, without downloading adware.

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question