Re: Troubles with User Permission

Tech-Archive recommends: Fix windows errors by optimizing your registry




"CharlyE" <CharlyE@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message news:745C11B2-89AE-45B2-B8AA-2D11992E214C@xxxxxxxxxxxxxxxx
Hi!

I am working with VB6 and XP Home Edition.

I experience trouble when trying to access the windows registry and my app
databases when the user has limited permission (i.e., has not system
administrator permission).
The databases, which are common for all users, are not accessible because
they are locked in read-only mode (so I can't write on them), and the windows
registry will not let me write on the HKEY_LOCAL_MACHINE key (where I need to
write user-independent information for my app).

Can anybody help and give some guidance on working with user permission from
within VB6 code?



Well, not sure about the database being read-only. That may or may not have anything to do with permissions or user privileges. You'd need to provide more information about this. For example, what is the database? Is it your own file format (i.e. you're using VB's file I/O statements and functions to read/write it). Is it an Access database? Some other RDMS? Where are the database files located? Regular users do not have permissions for many folders. For example, they may not have write permissions even to the application folder (the folder where your app is installed). This is why each user account has an Application Data (and other) folders under Documents and Settings. You might want to save your database files there. Since they are common for all users, you'd want them saved to "\Documents and Settings\All Users\Application Data" or perhaps "\Documents and Settings\All Users\Documents" (or a subfolder under either of these). Do NOT hard-code either of these paths in your app. Use the SHGetSpecialFolderPath Win32API function (and either CSIDL_COMMON_APPDATA or CSIDL_COMMON_DOCUMENTS) to get it. Search www.google.com if you need help or code examples for this function. If you need to support any Win9x systems, there will be alternate considerations.

As far as the Registry, if these are "user-independent" settings, you're saving them to the wrong place. You need to save them to HKEY_CURRENT_USER. HKEY_LOCAL_MACHINE is for system-wide settings and only admins and power users have write permissions to anything under it (Power users aren't very common under WinXP because it's not an "available" user account type..a user must be specifically added to the Power Users group). Regular users can read from HKEY_LOCAL_MACHINE, but not write to it. Also, when opening Registry keys, never use KEY_ALL_ACCESS. This does not "grant" permissions that a user doesn't have. Use KEY_READ or KEY_WRITE as appropriate for the operation you need to perform.

--
Mike
Microsoft MVP Visual Basic

.



Relevant Pages

  • Re: Creating Common Nodes for Forest
    ... > permissions on every single folder, registry item, file, ... > database, etc, in the entire domain?" ...
    (microsoft.public.windows.server.active_directory)
  • Re: 70 permission denied on Windows server 2008 TS
    ... app connects to an access 2000 database. ... file server ... For the Access database, everything is file-system permissions. ...
    (microsoft.public.data.ado)
  • Re: Registry ACL Modification
    ... What I will probably have to do is, modify the ACL of that key temporarily, ... run the app, and then modify the key back to the original permissions. ... I think you need to change the permissions in the registry to allow ...
    (microsoft.public.vb.winapi)
  • Re: Security question ..
    ... something other than our app, they will inherit the role and be able to make ... the front end connecting directly to the database, lots of dynamic sql, no ... a user's permissions to a database are ... > What's wrong with SQL authentication? ...
    (microsoft.public.sqlserver.server)
  • Re: Writing to registry
    ... We are talking writing settings to the registry ... You said you can't write to the App or windows directory. ... >>select Users and see what kind of permissions a user gets. ...
    (microsoft.public.vb.general.discussion)