Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Allow users to share database Windows 7

Posted on 2013-06-27
3
Medium Priority
?
335 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 83

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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

The Windows functions GetTickCount and timeGetTime retrieve the number of milliseconds since the system was started. However, the value is stored in a DWORD, which means that it wraps around to zero every 49.7 days. This article shows how to solve t…
There are many software programs on offer that will claim to magically speed up your computer. The best advice I can give you is to avoid them like the plague, because they will often cause far more problems than they solve. Try some of these "do it…
This Micro Tutorial will give you basic overview of the control panel section on Windows 7. It will depth in Network and Internet, Hardware and Sound, etc. This will be demonstrated using Windows 7 operating system.
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…
Suggested Courses

609 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