Solved

Allow users to share database Windows 7

Posted on 2013-06-27
3
315 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 78

Expert Comment

by:David Johnson, CD, MVP
Comment Utility
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
Comment Utility
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
Comment Utility
I need to ask a new question as the issue revolves around access rights to CommonApplicatonData
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

I recently purchased an HP EliteBook 2540p notebook/laptop. It has two video ports on it – VGA and DisplayPort. HP offers an optional docking station for the 2540p that also has both a VGA port and a DisplayPort. There are numerous online reports do…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
In this Micro Tutorial viewers will learn how to use Boot Corrector from Paragon Rescue Kit Free to identify and fix the boot problems of Windows 7/8/2012R2 etc. As an example is used Windows 2012R2 which lost its active partition flag (often happen…
This Micro Tutorial will give you a basic overview of Windows Live Photo Gallery and show you various editing filters and touches to photos you can apply. This will be demonstrated using Windows Live Photo Gallery on Windows 7 operating system.

763 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

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now