Solved

Allow users to share database Windows 7

Posted on 2013-06-27
3
329 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 81

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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
You may have a outside contractor who comes in once a week or seasonal to do some work in your office but you only want to give him access to the programs and files he needs and keep privet all other documents and programs, can you do this on a loca…
In this video, we discuss why the need for additional vertical screen space has become more important in recent years, namely, due to the transition in the marketplace of 4x3 computer screens to 16x9 and 16x10 screens (so-called widescreen format). …
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

696 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